import paramiko import os hostname="alias.im" port=22 username="guillaume" paramiko.util.log_to_file('sftp.log') t = paramiko.Transport((hostname, port)) keys = paramiko.Agent().get_keys() rsakeys = [key for key in keys if key.name=="ssh-rsa"] gkey = rsakeys[0] host_keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts')) hostkey = host_keys[hostname]['ssh-rsa'] t.connect(username="guillaume", hostkey=hostkey, pkey=gkey) sftp = paramiko.SFTPClient.from_transport(t) dirlist = sftp.listdir('.') print("Dirlist:", dirlist) t.close()