python:gaierror [错误-2]名称或服务未知sshTunnelForwarder

时间:2015-06-19 06:35:14

标签: python ssh-tunnel

以下代码给出了gaierror [错误-2]名称或服务未知的sshTunnelForwarder

self.server=sshtunnel.SSHTunnelForwarder(
                        ('abc.int.net', 22),
                        ssh_username="sshuser",
                        ssh_password="sshpassword",
                        remote_bind_address=('remote.address.host', 4040)
                        )

在Windows中工作正常

1 个答案:

答案 0 :(得分:0)

尝试传递local_bind_address参数。最好明确说明远程端口映射到哪个本地端口。

self.server=sshtunnel.SSHTunnelForwarder(
                    ('abc.int.net', 22),
                    ssh_username="sshuser",
                    ssh_password="sshpassword",
                    remote_bind_address=('remote.address.host', 4040),
                    local_bind_address=('127.0.0.1', 3331)
                    )