Fabric over reverse SSH tunnel

我怕爱的太早我们不能终老 提交于 2019-12-23 05:57:36

问题


Is there a trick to running Fabric over a reverse SSH tunnel? An interactive ssh connects fine back over the turnnel, but running fab, I just get asked for my password repeatedly.


回答1:


Here is a snippet with a solution

https://gist.github.com/856179

Just copy, paste and use




回答2:


Here's a solution that doesn't involve writing any extra Python code:

If you set up your SSH configuration to tunnel over a SOCKS proxy, you can tell Fabric to use the SSH configuration. It's sweet.

Example $HOME/.ssh/config file:

Host bastion
HostName bastion.yourdomain.com
DynamicForward 0.0.0.0:1080
ServerAliveInterval 120
ServerAliveCountMax 30

Host hostbehindthebastion.yourdomain.com
ProxyCommand /usr/bin/nc -x 127.0.0.1:1080 %h %p

Now tell Fabric to use the configuration:

env.use_ssh_config = True
env.hosts = [
    "user@hostbehindthebastion.yourdomain.com",
]

Now ssh bastion in one window, then run fab from another window.

See the official Fabric documentation for more information.

NB. You will have to have nc (netcat) installed on your machine to use this solution.



来源:https://stackoverflow.com/questions/5237893/fabric-over-reverse-ssh-tunnel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!