当尝试使用paramiko库ssh到Cisco ACS设备时,出现以下错误。我在python中使用了paramiko而没有问题,我可以从命令行ssh到这个框,或者使用putty而没有问题。我已经打开调试并将信息复制到这里。如果你能帮我,请告诉我。
import paramiko
import sys
import socket
try:
paramiko.common.logging.basicConfig(level=paramiko.common.DEBUG)
sshConnection = paramiko.SSHClient()
sshConnection.set_missing_host_key_policy(paramiko.AutoAddPolicy())
sshConnection.connect('server',username='username',password='password')
except paramiko.BadAuthenticationType:
sys.stdout.write('Bad Password!\n')
sys.exit()
except paramiko.SSHException, sshFail:
sys.stdout.write('Connection Failed!\n')
sys.stdout.write('%s\n' % sshFail)
sys.exit()
except socket.error, socketFail:
sys.stdout.write('Failed to open socket\n')
sys.stdout.write('%s\n' % socketFail)
sys.exit()
并且调试输出返回:
DEBUG:paramiko.transport:starting thread (client mode): 0x14511d0L
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_5.3)
DEBUG:paramiko.transport:kex algos:['diffie-hellman-group14-sha1'] server key:['ssh-rsa'] client encrypt:['aes256-cbc', 'aes128-cbc', '3des-cbc'] server encrypt:['aes256-cbc', 'aes128-cbc', '3des-cbc'] client mac:['hmac-sha1'] server mac:['hmac-sha1'] client compress:['none', 'zlib@openssh.com'] server compress:['none', 'zlib@openssh.com'] client lang:[''] server lang:[''] kex follows?False
ERROR:paramiko.transport:Exception: Incompatible ssh peer (no acceptable kex algorithm)
ERROR:paramiko.transport:Traceback (most recent call last):
ERROR:paramiko.transport: File "build\bdist.win32\egg\paramiko\transport.py", line 1546, in run
ERROR:paramiko.transport: self._handler_table[ptype](self, m)
ERROR:paramiko.transport: File "build\bdist.win32\egg\paramiko\transport.py", line 1618, in _negotiate_keys
ERROR:paramiko.transport: self._parse_kex_init(m)
ERROR:paramiko.transport: File "build\bdist.win32\egg\paramiko\transport.py", line 1731, in _parse_kex_init
ERROR:paramiko.transport: raise SSHException('Incompatible ssh peer (no acceptable kex algorithm)')
ERROR:paramiko.transport:SSHException: Incompatible ssh peer (no acceptable kex algorithm)
ERROR:paramiko.transport:
Connection Failed!
Incompatible ssh peer (no acceptable kex algorithm)
我已经确保安装了pycrypto和paramiko的最新版本。
我在服务器端的Debian 8和OpenSSH也有类似的问题。
作为快速修复,服务器端的以下Cipher/MACs/KexAlgorithms设置修复了此问题:
在/etc/ssh/sshd配置中:
不过。。。你应该从安全的角度分析这些设置。我把它放在实验室环境里,所以没在意。
也不确定你是否可以用这种方式修改思科ACS
如果其他人在使用
pip install paramiko --upgrade
升级后仍然存在此问题,请确保在系统范围内未安装paramiko,因为它将在pip之前加载,您可以使用dpkg -l | grep paramiko
检查它,如果已安装,请将其删除并通过pip安装。我升级了paramiko以解决问题:
我更新的paramiko版本是:
paramiko==2.0.2
相关问题 更多 >
编程相关推荐