今天在ubuntu 22.04系统上登录着,突然出现ssh远程登录香港服务器失败的问题;
1、首先确认服务器的:22端口的安全组权限已经开启,且ssh的公钥和实例正确绑定。
2、通过网页端用密码登录,
通过下边这一条命令可以观察ssh服务状态
sudo systemctl status ssh
发现这种日志
Unable to negotiate with x.x.x.x port 2222: no matching host key type found. Their offer: ssh-rsa
PS:如果没有安装还需要安装open-ssh,还需要安装
sudo apt install openssh-server
sudo systemctl enable ssh
解决:
在本机的~/.ssh/config中设置密钥的类型是ssh-rsa
添加以下两行:
Host xxx.xxx.xxx.xxx
Host xxx.xxx.xxx.xxx
AddKeysToAgent yes
UseKeychain yes
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes +ssh-rsa
IdentityFile ~/.ssh/id_rsa