大网数据广告活动
服务器运维问答

Upgrade path for HostKeyAlgorithms

· 52CE 我爱测

I'd like to change the default setting for HostKeyAlgorithms for all SSH connections to prefer ssh-ed25519 over ecdsa-sha2-nistp256 . But I currently have ecdsa-sha2-nistp256 host keys for many hosts in my known_hosts file (about…

问题原文

原帖链接 · Feuermurmel · CC BY-SA 3.0

I'd like to change the default setting for HostKeyAlgorithms for all SSH connections to prefer ssh-ed25519 over ecdsa-sha2-nistp256. But I currently have ecdsa-sha2-nistp256 host keys for many hosts in my known_hosts file (about 70). When I connect to such a host with the new setting, I get the same message as if someone replaced the host key on that host:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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.

Now I would rather not have to remove all those host from my known_hosts file and accept the "new" ED25519 keys on the next connection. Rather I'd like to have a way to continue with the existing contents of that file. Is there any way to do this? E.g. by falling back to the known host key even when is not using the preferred algorithm. Or is there an automated way to replace all those entries?

已采纳解答

原帖链接 · Jakuje · CC BY-SA 3.0

I was answering similar question on Unix so to make it short, in OpenSSH 6.8+ there is option UpdateHostKeys, which says to your client that it should pick up all the host keys offered by server.

This should resolve your problems.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。