RIAPS / riaps-pycom

Python implementation of the RIAPS component model
Apache License 2.0
7 stars 8 forks source link

Execution error of fabfile from a remote access to RIAPS VM #148

Closed nie93 closed 5 years ago

nie93 commented 5 years ago

Hi!

I am using my computer (192.168.1.104) to ssh access to a remote desktop (192.168.1.101) that runs RIAPS VM (configured static ip address 192.168.1.201, and the virtualbox process started from 192.168.1.104 via ssh). Because the GUI response from 192.168.1.101 is slow, I would like to ssh into RIAPS VM (192.168.1.201) from 192.168.1.104 directly.

So I was trying to use the fabfile commands like fab sys.check from a remote computer to access the RIAPS devbox VM, which returned the following error messages:

riaps@riaps-devbox:~$ fab sys.check
[bbb-2b6c.local] Executing task 'sys.check'
!!! Parallel execution exception under host 'bbb-2b6c.local':
Process bbb-2b6c.local:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/fabric/network.py", line 478, in connect
    client.connect(**kwargs)
  File "/usr/local/lib/python3.6/dist-packages/paramiko/client.py", line 424, in connect
    passphrase,
  File "/usr/local/lib/python3.6/dist-packages/paramiko/client.py", line 643, in _auth
    self._agent = Agent()
  File "/usr/local/lib/python3.6/dist-packages/paramiko/agent.py", line 372, in __init__
    self._connect(conn)
  File "/usr/local/lib/python3.6/dist-packages/paramiko/agent.py", line 68, in _connect
    raise SSHException('could not get keys from ssh-agent')
paramiko.ssh_exception.SSHException: could not get keys from ssh-agent

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fabric/tasks.py", line 242, in inner
    submit(task.run(*args, **kwargs))
  File "/usr/local/lib/python3.6/dist-packages/fabric/tasks.py", line 174, in run
    return self.wrapped(*args, **kwargs)
  File "/home/riaps/fabfile/sys.py", line 13, in check
    run('hostname && uname -a')
  File "/usr/local/lib/python3.6/dist-packages/fabric/tasks.py", line 171, in __call__
    return self.run(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fabric/tasks.py", line 174, in run
    return self.wrapped(*args, **kwargs)
  File "/home/riaps/fabfile/sys.py", line 40, in run
    result = api.run(command)
  File "/usr/local/lib/python3.6/dist-packages/fabric/network.py", line 692, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/fabric/operations.py", line 1095, in run
    shell_escape=shell_escape, capture_buffer_size=capture_buffer_size,
  File "/usr/local/lib/python3.6/dist-packages/fabric/operations.py", line 935, in _run_command
    channel=default_channel(), command=wrapped_command, pty=pty,
  File "/usr/local/lib/python3.6/dist-packages/fabric/state.py", line 435, in default_channel
    chan = _open_session()
  File "/usr/local/lib/python3.6/dist-packages/fabric/state.py", line 416, in _open_session
    transport = connections[env.host_string].get_transport()
  File "/usr/local/lib/python3.6/dist-packages/fabric/network.py", line 156, in __getitem__
    self.connect(key)
  File "/usr/local/lib/python3.6/dist-packages/fabric/network.py", line 148, in connect
    user, host, port, cache=self, seek_gateway=seek_gateway)
  File "/usr/local/lib/python3.6/dist-packages/fabric/network.py", line 533, in connect
    raise NetworkError(msg, e)
fabric.exceptions.NetworkError: could not get keys from ssh-agent

Fatal error: One or more hosts failed while executing task 'sys.check'

Underlying exception:
    could not get keys from ssh-agent

Aborting.

But if I run the fab command on VM directly, it returns the discovered uname information on BBB without any error.

MMetelko commented 5 years ago

You must be able to do a passwordless ssh into the hosts listed in the riaps_hosts.py. So check that you have the public key included in the authorized_key file on your remote machine.

nie93 commented 5 years ago

When I ssh from VM (192.168.1.201) to BBB (bbb-xxxx.local), it does not require password since I add the VM's public key to the authorized key file on BBB already.

nie93 commented 5 years ago

If I use sudo at the beginning, this issue does not exist any more.

riaps@riaps-devbox:~$ sudo fab sys.check
[bbb-2b6c.local] Executing task 'sys.check'
[bbb-2b6c.local] hostname && uname -a
bbb-2b6c
Linux bbb-2b6c 4.14.71-ti-rt-r78 #1 SMP PREEMPT RT Tue Sep 25 23:47:31 UTC 2018 armv7l armv7l armv7l GNU/Linux

Done.