1
如何指定一個不同的密碼在paramiko ssh/sftp連接上使用? (類似於scp/ssh的-c命令行)。與paramiko使用不同的密碼
我曾嘗試下面的代碼:
self.sshclient = paramiko.SSHClient()
self.sshclient.load_system_host_keys()
self.sshclient.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.sshclient.connect(hostname, **ssh_kwargs)
self.transport = self.sshclient.get_transport()
self.transport.get_security_options().ciphers = ('arcfour128',)
self.transport.set_keepalive(keepalive)
self.channel = self.transport.open_session()
self.channel.settimeout(timeout)
但在調試,我可以看到:
2016/02/26 15:27:47 DEBUG Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
2016/02/26 15:27:47 DEBUG using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none
我看過的地方,連接應get_security_options()
以後的事情了,倒引起了我self.transport
是NoneType
(似乎運輸與連接有關)。