升级到新版SSH遇到的问题


问题描述

安装了新版 OpenSSH 后,发现以前的服务器连不上了。

1
ssh -i stark.pem -p 1234 stark@192.168.1.111

报错信息:

1
Unable to negotiate with 192.168.1.111 port 1234: no matching host key type found. Their offer: ssh-rsa

解决方法

方法一:命令行指定密钥类型

1
ssh -i stark.pem -p 1234 -o HostKeyAlgorithms=+ssh-rsa stark@192.168.1.111

方法二:配置文件永久生效

编辑 ~/.ssh/config

1
2
3
4
vim ~/.ssh/config

Host *
PubkeyAcceptedKeyTypes=+ssh-rsa

设置权限:

1
chmod 600 ~/.ssh/config

说明

新版本 OpenSSH 默认废弃了 ssh-rsa 加密方式,以上两种方法都可以解决连接问题。

方法一适合临时连接,方法二适合长期使用。