好的@Adam和@Kimvais是正确的,paramiko无法解析.ppk文件。
因此,方法(也要感谢@JimB)是将.ppk文件转换为openssh私钥格式;这可以使用来实现的puttygen描述这里。
然后,很简单地与之建立联系:
import paramikossh = paramiko.SSHClient()ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())ssh.connect('<hostname>', username='<username>', password='<password>', key_filename='<path/to/openssh-private-key-file>')stdin, stdout, stderr = ssh.exec_command('ls')print stdout.readlines()ssh.close()


