我正在使用Paramiko通过sftp连接到服务器。但是我不明白如何与以下Putty用户密钥文件连接
代码:
local_path = "C:\blp\aisrvintraday1045.csv"
remote_path = "/aisrvintraday1045.csv"
cnopts = pysftp.CnOpts ()
cnopts.hostkeys.load('C:\Python code\SSH-KEY-08142018(private).ppk')
with pysftp.Connection (host='sftp.bloomberg.com', username='user', password='pass', cnopts=cnopts) as sftp:
sftp.get(local_path, remote_path)
data = sftp.listdir ()
for i in data:
print(i)
sftp.close()
我用这个ppk文件连接到它:
PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: rsa-key@20180814
Public-Lines: 12
[12 lines key]
Private-Lines: 28
[28 lines key]
Private-MAC: [hash]
错误:
(<class 'paramiko.ssh_exception.SSHException'>, SSHException('Bad host key
from server',), <traceback object at 0x7fa76269c5a8>)
Bad host key from server
我尝试包含该ppk文件并将其设置为auth_public_key,但是没有用。
能帮我吗?我很努力。