【发布时间】:2023-02-23 01:56:13
【问题描述】:
帕拉米科 2.11.0
import paramiko
import io
host = "sftp.host.com"
port = 2222
username = username
private_key_file = io.StringIO()
private_key_file.write('-----BEGIN RSA PRIVATE KEY-----\nAAAAB3NzaC\n-----END RSA PRIVATE KEY-----\n')
private_key_file.seek(0)
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=host,port=port,username=username,pkey=private_key_file)
错误:
in missing_host_key(self, client, hostname, key)
837 ),
838 )
\--\> 839 raise SSHException(
840 "Server {!r} not found in known_hosts".format(hostname)
841 )
SSHException: Server '\[sftp.host.com\]:2222' not found in known_hosts
如果我添加:
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
"Error: AttributeError: '\_io.StringIO' object has no attribute 'get_fingerprint' "
【问题讨论】:
-
这些似乎是两个不同的问题(尽管您没有发布异常的堆栈跟踪,所以很难说)。你想解决哪一个?