场景描述:在docker容器中执行ssh连接虚拟机的脚本任务,docker容器报错
出现下面的错误信息。
错误信息是使用命令journalctl -xe来查看的。
Jan 07 09:28:02 k8s-master01 sshd[49202]: Unable to negotiate with 10.10.10.88 port 43112: no matching host key type found. Their offer: sk-ecdsa-sha2-nistp256@openssh.com [preauth]
Jan 07 09:28:02 k8s-master01 sshd[49203]: Unable to negotiate with 10.10.10.88 port 43114: no matching host key type found. Their offer: sk-ssh-ed25519@openssh.com [preauth]
上面信息因为是需要,连接到10.10.10.88这台服务器的。
查看下版本
sshd -V
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
解决方法是:
第一步、
touch ~/.ssh/authorized_keys
第二步、
chmod 600 ~/.ssh/authorized_keys
第三步、
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
第四步、
ssh-keygen -t ed25519
第五步、
cat ~/.ssh/id_ed25519.pub >> ~/.ssh/authorized_keys
第六步、
ssh-keygen -t dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
第七步、
reboot重启机器