登录机器时报错:Unable to negotiate with x.x.x.x port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

根本原因是:OpenSSH7.0以后的版本不再支持ssh-dss(DSA)算法,官方的说法是这个算法太弱了。MACOS升到10.12附带的openssh
版本是7.4,如下:➜~sshd-Vsshd:illegaloption–VOpenSSH_7

方案一 命令行添加选项 ssh -oHostKeyAlgorithms=+ssh-dss user@host -p port

ssh -oHostKeyAlgorithms=+ssh-rsa 用户名@ip地址

示例:
sftp -P 20001 -oHostKeyAlgorithms=+ssh-dss test@192.168.10.128
ssh -oHostKeyAlgorithms=+ssh-dss root@www.xxx.cn

方案二:在ssh的配置文件中添加全局选项

HostKeyAlgorithms +ssh-dss

  • 添加到配置 ~/.ssh/config
  • 添加到 /etc/ssh/ssh_config
方案三:在 ~/.ssh/config 中添加下面几行

HostKeyAlgorithms ssh-rsa
PubkeyAcceptedKeyTypes ssh-rsa

参考链接:
https://www.twle.cn/t/90568
https://blog.csdn.net/u013214821/article/details/122804133
mac下使用配置文件config, SSH连接服务器:https://blog.csdn.net/Enceladuce/article/details/102372590

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐