6

I know with Paramiko's SSHClient class, you can set a relaxed missing host key policy like so:

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

However, I'm opening a file stream via SFTP (not SSHClient), like so:

t = paramiko.Transport((process['hostname'], 22))
keyfile = paramiko.DSSKey.from_private_key_file('./id_dsa')
t.connect(username = 'user', pkey = keyfile)
sftp = paramiko.SFTPClient.from_transport(t)

I couldn't locate anything in the docs for setting a missing host key policy via Transport, or SFTPClient.

Is there any way to achieve the same thing using SFTPClient?

Cheers, Victor

1 Answer 1

12

One can get SFTP client from SSH client by using open_sftp().

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

sftp = ssh.open_sftp() 
sftp.get('remotefile', 'localfile')

Though I haven't tested this.

1
  • 1
    I have a connection that I can not make an ssh connection because of the restrictions on the server. How do I check the policy using transport and sftp clients?
    – isaaclw
    Feb 22, 2021 at 18:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.