我想更改所有SSH连接的默认设置HostKeyAlgorithms更喜欢ssh-ed25519通过ecdsa-sha2-nistp256 。 但是我目前在我的known_hosts文件(大约70)中有很多主机的ecdsa-sha2-nistp256主机密钥。 当我用新的设置连接到这样的主机时,我得到了相同的消息,就好像有人在主机上replace了主机密钥一样:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ED25519 key sent by the remote host is SHA256:rqhdlN+Qe/GJeWoj3pyhLLSnzSCz68ZA7ds+mG4iZ7o. Please contact your system administrator. Add correct host key in [...]/.ssh/known_hosts to get rid of this message. Offending ECDSA key in [...]/.ssh/known_hosts:52 ED25519 host key for [...] has changed and you have requested strict checking. Host key verification failed.
现在,我宁愿不必从我的known_hosts文件中删除所有这些主机,并接受下一个连接上的“新”ED25519密钥。 相反,我想有一个方法来继续该文件的现有内容。 有没有办法做到这一点? 例如,即使不使用首选algorithm,也可以回退到已知的主机密钥。 还是有自动的方式来取代所有这些条目?
我在Unix上回答了类似的问题,所以为了简短UpdateHostKeys ,在OpenSSH UpdateHostKeys有选项UpdateHostKeys ,它告诉你的客户它应该拿起服务器提供的所有主机密钥。
这应该可以解决你的问题。