You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SSH主机密钥轮换后客户端known_hosts未更新的问题求助

SSH主机密钥轮换后客户端known_hosts未更新的问题求助

各位好,我最近在serverA上做了SSH主机密钥轮换的操作,步骤如下:

  • 生成新的ED25519主机密钥
cd /etc/ssh
sudo ssh-keygen -f 2024_ssh_host_ed25519_key -t ed25519 -N ''
  • 修改sshd_config配置文件,添加新的主机密钥路径
sudo vi /etc/ssh/sshd_config

在配置里加了这一行:HostKey /etc/ssh/2024_ssh_host_ed25519_key

  • 重启SSH服务
sudo service ssh restart

之后我用客户端连接serverA的时候,特意加了-v -o UpdateHostKeys=yes参数,结果发现客户端的known_hosts根本没更新。SSH的调试输出里有这么一段关键内容:

debug1: Host '[serverA.domain.internal]:22' is known and matches the ED25519 host key.

...

debug1: client_input_hostkeys: searching /Users/snafu/.ssh/known_hosts for [serverA.domain.internal]:22 / (none)
debug1: client_input_hostkeys: searching /Users/snafu/.ssh/known_hosts2 for [serverA.domain.internal]:22 / (none)
debug1: client_input_hostkeys: hostkeys file /Users/snafu/.ssh/known_hosts2 does not exist
debug1: client_input_hostkeys: host key found matching a different name/address, skipping UserKnownHostsFile update

看起来问题出在最后那句“host key found matching a different name/address, skipping UserKnownHostsFile update”,我猜是客户端的known_hosts里已经存在这个主机的其他关联条目?有没有人遇到过类似的情况?怎么才能让客户端成功更新新的主机密钥到known_hosts里呢?

备注:内容来源于stack exchange,提问作者janeden

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 13:03:07