刚刚在用 SSH 连接远程服务器的时候,出现一下错误信息:
[root@VM_224_197_centos ~]# python test.py
No handlers could be found for logger "ssh.transport"
Traceback (most recent call last):
File "remote.py", line 9, in <module>
client.connect("192.168.1.100", port=22, username="username", password="password")
File "/usr/lib/python2.7/site-packages/ssh/client.py", line 302, in connect
t.start_client()
File "/usr/lib/python2.7/site-packages/ssh/transport.py", line 464, in start_client
raise e
ssh.SSHException: Incompatible ssh peer (no acceptable kex algorithm)
查了一下 SSH 的版本, 发现版本号大于 6.7,这是由于高版本的 SSH 不支持不安全算法。
[root@VM_224_197_centos ~]# ssh -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
于是在/etc/ssh/sshd_conf
最后一行加上一下代码,然后重启 SSH service sshd restart
即可。
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1