背景:使用centos7设备 ssh远程连接ensp中的华为交换机 交换机ip:192.168.164.11 centos7虚拟机ip:192.168.164.128
ssh连接语法: ssh user@ip地址
1. 远程设备RSA密钥发生变化
需要重新生成密钥

解决方式:
1.清除密钥
ssh-keygen -R 192.168.164.11 #(远程服务器的IP)
2.重新连接
ssh python@192.168.164.11
另:linux系统生成密钥的指令
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
2.RSA key长度不匹配
1.修改ensp交换机的rsa key长度为2048
rsa local-key-pair create
#提示key长度的时候 输入2048
2.ssh连接命令中指定key长度
ssh python@192.168.164.11 ssh-keygen -b 2048
3.DH grou 不匹配
错误码类似于:
Unable to negotiate with legacyhost: no matching key exchange method found.
Their offer: diffie-hellman-group1-sha1
解决方式:
1.在连接指令中加入DH group参数
ssh -o KexAlgorithms=+diffie-hellman-group1-sha1 user@legacyhost
2.修改ssh配置文件
#在/etc/ssh/ssh_config文件内添加以下内容
Host *
KexAlgorithms +diffie-hellman-group1-sha1
# Host 192.168.164.11 (ip或域名,按需开启)
#重启ssh服务
systemctl restart sshd
DH组决定密匙长度 , 实际上还是密钥长度不匹配的原因。
4. ssh加密算法不一致
例如对端使用的是dsa算法,本端默认使用rsa算法 报错类似于
Unable to negotiate with legacyhost: no matching host key type found. Their offer: ssh-dss
解决方式
1.连接指令中指定主机密钥算法
ssh -o HostKeyAlgorithms=+ssh-dss user@legacyhost
#ssh-dss 表示dsa加密算法; ssh-rsa 表示rsa加密算法。
2.修改配置文件 /etc/ssh/ssh_config (或用户配置 ~/.ssh/config)
#加入如下配置
HostKeyAlgorithms +ssh-dss
# Host (域名或IP,按需开启)
#重启ssh服务
systemctl restart sshd
















