使用打开SSH会话时“拒绝连接”帕拉米科运输公司

2024-10-01 17:27:27 发布

您现在位置:Python中文网/ 问答频道 /正文

使用Paramiko进行SFTP连接时出现问题。在

我试过以下方法:

transport = paramiko.Transport(sftpHost, 22)
myKey = paramiko.RSAKey.from_private_key_file(rsaKeyFileSpec)
transport.connect(username = sftpUser, pkey = myKey)
sftp = paramiko.SFTPClient.from_transport(transport)

我得到的答复是:

paramiko.ssh_exception.SSHException: Unable to connect to HOST: [Errno 111] Connection refused

我做错什么了?在


Tags: to方法keyfromparamikoconnectprivatefile
1条回答
网友
1楼 · 发布于 2024-10-01 17:27:27

它应该是:

transport = paramiko.Transport((sftpHost, 22))

或者

^{pr2}$

^{} constructor是:

__init__(sock, default_window_size=2097152, default_max_packet_size=32768, gss_kex=False, gss_deleg_creds=True)

Create a new SSH session over an existing socket, or socket-like object.

...

For ease of use, you may also pass in an address (as a tuple) or a host string as the sock argument. (A host string is a hostname with an optional port (separated by ":") which will be converted into a tuple of (hostname, port).)

相关问题 更多 >

    热门问题