我使用密钥SSH进入Digital Ocean。形成命令行..工作
ssh root@111.111.111.111
The authenticity of host 111.111.111.111 (111.111.111.111)' can't be established.
ECDSA key fingerprint is 7f:89:a8:ff:ca:de:5a:30:b9:a1:ff:6a:d6:91:90:4b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '111.111.111.111' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-virtual x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Fri Jul 19 19:54:48 2013 from 111.111.111.111
使用paramiko时,它会永远挂起
import paramiko
ssh = paramiko.SSHClient()
privatekeyfile = '/home/ubuntu/.ssh/id_rsa'
mykey = paramiko.RSAKey.from_private_key_file(privatekeyfile)
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('111.111.111.111', username = 'root', pkey = mykey)
那么..为什么paramiko不会在带有id_rsa键的DO上工作?我对ec2 pem文件和相同代码没有任何问题。
DEBUG:paramiko.transport:starting thread (client mode): 0x1fc5610L
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_5.9p1)
DEBUG:paramiko.transport:kex algos:['ecdh-sha2-nistp256', 'ecdh-sha2-nistp384', 'ecdh-sha2-nistp521', 'diffie-hellman-group-exchange-sha256', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256'] client encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-cbc@lysator.liu.se'] server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', 'rijndael-cbc@lysator.liu.se'] client mac:['hmac-md5', 'hmac-sha1', 'umac-64@openssh.com', 'hmac-sha2-256', 'hmac-sha2-256-96', 'hmac-sha2-512', 'hmac-sha2-512-96', 'hmac-ripemd160', 'hmac-ripemd160@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'umac-64@openssh.com', 'hmac-sha2-256', 'hmac-sha2-256-96', 'hmac-sha2-512', 'hmac-sha2-512-96', 'hmac-ripemd160', 'hmac-ripemd160@openssh.com', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', 'zlib@openssh.com'] server compress:['none', 'zlib@openssh.com'] client lang:[''] server lang:[''] kex follows?False
DEBUG:paramiko.transport:Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
DEBUG:paramiko.transport: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
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Adding ssh-rsa host key for 192.241.198.138: a1f959beaa5227e98239face34cdfd74
DEBUG:paramiko.transport:Trying SSH key f3b35cd0d539efed90a8665bff9b905b