paramiko.Proxycommand fails to setup socket

旧巷老猫 提交于 2019-12-05 15:54:03

I think you can stick to your first solution. Just you need to change your proxy command and make sure your jump host has got nc installed

I use a proxy command like this

proxy = paramiko.ProxyCommand("ssh -o StrictHostKeyChecking=no jumphostIP nc targethostIP 22")

I found this WiKi very useful http://en.wikibooks.org/wiki/OpenSSH/Cookbook/Proxies_and_Jump_Hosts Just use actual values instead of %h and %p as I have done.

jimmy

So instead of using ProxyCommand I used port forwarding to solve my issue.

def getForwardedSSHPort(self, tunnnelHostName):
    forwarderClient = self.getSSHConnection(tunnnelHostName, None)
    transport = forwarderClient.get_transport()
    dest_addr = ('169.254.1.2', 22)
    local_addr = ('127.0.0.1', 10022)
    channel = transport.open_channel('direct-tcpip', dest_addr, local_addr)

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