使用 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
我做错了什么?
最佳答案
应该是:
transport = paramiko.Transport((sftpHost, 22))
或
transport = paramiko.Transport(sftpHost)
__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).)
关于python - 使用 paramiko.Transport 打开 SSH session 时出现 "Connection refused",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42169275/