【发布时间】:2016-02-18 09:43:27
【问题描述】:
虽然我可以正常使用 ssh 命令连接到服务器:
>[ec2-user@dsi_valid_env:~/scripts]$ssh test@172.XX.YY.ZZ
>test@172.XX.YY.ZZ's password:
但我正在努力为 python 脚本连接 paramiko:
>>> import paramiko
>>> ssh = paramiko.SSHClient()
>>> ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
>>> ssh.connect("172.XX.YY.ZZ",username="test",password="test")
paramiko.ssh_exception.SSHException: could not get keys from ssh-agent
你知道我做错了什么吗?
在我的 ssh.connect 的调试堆栈跟踪下方:
ssh.connect("172.XX.YY.ZZ",username="test",password="test")
DEBUG:paramiko.transport:starting thread (client mode): 0x24532d0L
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_5.3)
DEBUG:paramiko.transport:kex algos:[u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group-exchange-sha1', u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa', u'ssh-dss'] client encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'rijndael-cbc@lysator.liu.se'] server encrypt:[u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'arcfour256', u'arcfour128', u'aes128-cbc', u'3des-cbc', u'blowfish-cbc', u'cast128-cbc', u'aes192-cbc', u'aes256-cbc', u'arcfour', u'rijndael-cbc@lysator.liu.se'] client mac:[u'hmac-md5', u'hmac-sha1', u'umac-64@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-ripemd160', u'hmac-ripemd160@openssh.com', u'hmac-sha1-96', u'hmac-md5-96'] server mac:[u'hmac-md5', u'hmac-sha1', u'umac-64@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-ripemd160', u'hmac-ripemd160@openssh.com', u'hmac-sha1-96', u'hmac-md5-96'] client compress:[u'none', u'zlib@openssh.com'] server compress:[u'none', u'zlib@openssh.com'] client lang:[u''] server lang:[u''] kex follows?False
DEBUG:paramiko.transport:Ciphers agreed: local=aes128-ctr, remote=aes128-ctr
DEBUG:paramiko.transport:using kex diffie-hellman-group14-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 ...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/paramiko/client.py", line 307, in connect
look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host)
File "/usr/lib/python2.6/dist-packages/paramiko/client.py", line 456, in _auth
self._agent = Agent()
File "/usr/lib/python2.6/dist-packages/paramiko/agent.py", line 339, in __init__
self._connect(conn)
File "/usr/lib/python2.6/dist-packages/paramiko/agent.py", line 68, in _connect
raise SSHException('could not get keys from ssh-agent')
paramiko.ssh_exception.SSHException: could not get keys from ssh-agent
【问题讨论】:
标签: python amazon-web-services paramiko