【linux】SCP或SSH 连接失败: no matching host key type found. Their offer: ssh-rs
scp或者ssh报错“no matching host key type found. Their offer: ssh-rsa,ssh-dss“
原因:OpenSSH 7.0以后的版本不再支持ssh-dss (DSA)算法
aab@aab-virtual-machine:~/桌面/lianxi$ scp text.c root@192.168.1.50:/home/root
Unable to negotiate with 192.168.1.50 port 22: no matching host key type found. Their offer: ssh-rsa
lost connection
或者
root:~ >ssh root@192.168.1.133
Unable to negotiate with 192.168.1.133 port 22: no matching host key type found. Their offer: ssh-rsa
解决办法:
ssh -i key.pem shell@x.x.x.x -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa
1每次指令后加上-oHostKeyAlgorithms=+ssh-dss或者-oHostKeyAlgorithms=+ssh-dsa:
2.(推荐)也可以把参数加到 ssh config file, /etc/ssh/ssh_config :,增加以下内容:
HostKeyAlgorithms = +ssh-rsa
PubkeyAcceptedAlgorithms = +ssh-rsa
退出 SSH 连接的方法有以下几种
- 使用 exit 命令。
- 使用 logout 命令。
- 使用 Ctrl + D 键盘组合。
- 如果 SSH 连接被冻结,可以键入 ~. 关闭 SSH 会话并返回到本地命令行终端。
