Adrián
2013-10-02 17:38:09 UTC
Hi,
I'm trying to use the tunnel functionality in Fabric to execute commands on
a remote machine through a bastion host. However, right after being
prompted for the password it stalls and nothing happens. It's also quite
unclear which password you're entering, but that's not an issue because
I've set up the same password and user in both boxes for the tests. The
code I'm using is pasted below.
from fabric.api import run, env
env.no_keys=True
env.host_string='***@destination_host:22'
env.gateway='***@bastion_host:4242'
run("uname -a")
And the output from running it looks like this:
adrian$ python test-tunnels.py
[***@destination_host:22] run: uname -a
[***@destination_host:22] Login password for 'adrian':
[***@destination_host:22] Login password for 'adrian':
After entering the password twice, it stalls, nothing else happens. If I
hit Ctrl-C, this is the stack trace it produces:
^CTraceback (most recent call last):
File "tunnels.py", line 7, in <module>
run("uname -a")
File "/Library/Python/2.7/site-packages/fabric/network.py", line 578, in
host_prompting_wrapper
return func(*args, **kwargs)
File "/Library/Python/2.7/site-packages/fabric/operations.py", line 1042,
in run
shell_escape=shell_escape)
File "/Library/Python/2.7/site-packages/fabric/operations.py", line 909,
in _run_command
channel=default_channel(), command=wrapped_command, pty=pty,
File "/Library/Python/2.7/site-packages/fabric/state.py", line 388, in
default_channel
chan = _open_session()
File "/Library/Python/2.7/site-packages/fabric/state.py", line 380, in
_open_session
return connections[env.host_string].get_transport().open_session()
File "/Library/Python/2.7/site-packages/fabric/network.py", line 118, in
__getitem__
self.connect(key)
File "/Library/Python/2.7/site-packages/fabric/network.py", line 110, in
connect
self[key] = connect(user, host, port, sock)
File "/Library/Python/2.7/site-packages/fabric/network.py", line 392, in
connect
sock=sock
File "/Library/Python/2.7/site-packages/paramiko/client.py", line 311, in
connect
t.start_client()
File "/Library/Python/2.7/site-packages/paramiko/transport.py", line 462,
in start_client
event.wait(0.1)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 394, in wait
self.__cond.wait(timeout)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 257, in wait
_sleep(delay)
KeyboardInterrupt
I'm sure it's not a SSH problem, since the tunneling command in SSH works.
I say more, I was looking online for an answer and I came across this (
https://gist.github.com/shnjp/856179), that also works for the same
boxes/users. I wonder how that one is different from the built in mechanism
into Fabric. I've gone through the documentation and I've not been able to
find what I'm doing wrong, so if anyone could shed any light onto this I'd
appreciate it very much.
Regards,
Adrian
I'm trying to use the tunnel functionality in Fabric to execute commands on
a remote machine through a bastion host. However, right after being
prompted for the password it stalls and nothing happens. It's also quite
unclear which password you're entering, but that's not an issue because
I've set up the same password and user in both boxes for the tests. The
code I'm using is pasted below.
from fabric.api import run, env
env.no_keys=True
env.host_string='***@destination_host:22'
env.gateway='***@bastion_host:4242'
run("uname -a")
And the output from running it looks like this:
adrian$ python test-tunnels.py
[***@destination_host:22] run: uname -a
[***@destination_host:22] Login password for 'adrian':
[***@destination_host:22] Login password for 'adrian':
After entering the password twice, it stalls, nothing else happens. If I
hit Ctrl-C, this is the stack trace it produces:
^CTraceback (most recent call last):
File "tunnels.py", line 7, in <module>
run("uname -a")
File "/Library/Python/2.7/site-packages/fabric/network.py", line 578, in
host_prompting_wrapper
return func(*args, **kwargs)
File "/Library/Python/2.7/site-packages/fabric/operations.py", line 1042,
in run
shell_escape=shell_escape)
File "/Library/Python/2.7/site-packages/fabric/operations.py", line 909,
in _run_command
channel=default_channel(), command=wrapped_command, pty=pty,
File "/Library/Python/2.7/site-packages/fabric/state.py", line 388, in
default_channel
chan = _open_session()
File "/Library/Python/2.7/site-packages/fabric/state.py", line 380, in
_open_session
return connections[env.host_string].get_transport().open_session()
File "/Library/Python/2.7/site-packages/fabric/network.py", line 118, in
__getitem__
self.connect(key)
File "/Library/Python/2.7/site-packages/fabric/network.py", line 110, in
connect
self[key] = connect(user, host, port, sock)
File "/Library/Python/2.7/site-packages/fabric/network.py", line 392, in
connect
sock=sock
File "/Library/Python/2.7/site-packages/paramiko/client.py", line 311, in
connect
t.start_client()
File "/Library/Python/2.7/site-packages/paramiko/transport.py", line 462,
in start_client
event.wait(0.1)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 394, in wait
self.__cond.wait(timeout)
File
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",
line 257, in wait
_sleep(delay)
KeyboardInterrupt
I'm sure it's not a SSH problem, since the tunneling command in SSH works.
I say more, I was looking online for an answer and I came across this (
https://gist.github.com/shnjp/856179), that also works for the same
boxes/users. I wonder how that one is different from the built in mechanism
into Fabric. I've gone through the documentation and I've not been able to
find what I'm doing wrong, so if anyone could shed any light onto this I'd
appreciate it very much.
Regards,
Adrian