问题
I've been using paramiko for a while and everything has worked as expected, but when I moved out of my testing environment, I got this error when opening an ssh session
paramiko.ssh_exception.SSHException: Incompatible ssh server (no acceptable macs)
After tracing down the error, I noticed that on my remote server, I'm missing some entries in my /etc/ssh/sshd_config
file. Neither of my setups have these MACs listed:
- HMAC-SHA1
- HMAC-MD5
- HMAC-SHA1-96
- HMAC-MD5-96
However, it works in one and not the other. What could be causing this? I don't have rsa keys saved in either one (remote server does not allow for writing).
Remote server's sshd_config
#
# Allow Ciphers and MACs
#
Ciphers aes256-ctr,aes192-ctr,aes128-ctr,arcfour256,arcfour128
MACs umac-64@openssh.com,hmac-ripemd160,hmac-sha2-512,hmac-sha2-256
RemoteAccess.py
class RemoteAccess():
def __init__(self, host="abc123", username="abc", password="123"):
self.name = host
self.client = paramiko.SSHClient()
self.client.load_system_host_keys()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
self.client.connect(host, username=username, password=password)
Links I've referenced:
Python - Paramiko - incompatible ssh server
paramiko Incompatible ssh peer (no acceptable kex algorithm)
回答1:
For some reason, paramiko1.15.1 would complain about incompatible MACs. paramiko1.16.0 did not. This was fixed by copying 1.16.0 files to its installation location.
/usr/lib/python2.7/site-packages/paramiko
Changelog for paramiko versions can be found here: http://www.paramiko.org/changelog.html
来源:https://stackoverflow.com/questions/36561792/paramiko-incompatible-ssh-server-no-acceptable-macs