i'm using Paramiko to connect through sftp to a server.but i can't understand how to connect with below Putty User key file
Code:
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()
I connect to it with this ppk file:
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]
Error:
(<class 'paramiko.ssh_exception.SSHException'>, SSHException('Bad host key
from server',), <traceback object at 0x7fa76269c5a8>)
Bad host key from server
I've tried to include that ppk file and set to auth_public_key, but didn't work.
Can you please help me? I am struggling for long time.