eww*_*ite 41 linux ssh command-line-interface ssh-keys
这是一个我们都面临的简单问题,可能无需多想就手动解决。
随着服务器更改、重新配置或重新分配 IP 地址,我们会收到以下 SSH 主机验证消息。我对简化工作流程以解决这些 ssh 识别错误很感兴趣。
鉴于以下消息,我通常会vi /root/.ssh/known_hosts +434
删除 ( dd
) 违规行。
我已经看到其他组织的开发人员/用户在看到此消息时出于沮丧而删除了他们的整个 known_hosts
文件。虽然我没有走那么远,但我知道有一种更优雅的方法来处理这个问题。
提示?
[root@xt ~]# ssh las-db1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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 the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
ed:86:a2:c4:cd:9b:c5:7a:b1:2b:cc:42:15:76:8c:56.
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending key in /root/.ssh/known_hosts:434
RSA host key for las-db1 has changed and you have requested strict checking.
Host key verification failed.
Run Code Online (Sandbox Code Playgroud)
Kyl*_*ndt 47
您可以使用该ssh-keygen
命令按主机删除特定条目:
ssh-keygen -R las-db1
Run Code Online (Sandbox Code Playgroud)
如果您没有该命令,则始终可以使用 sed:
sed -i '/las-db1/d' /root/.ssh/known_hosts
Run Code Online (Sandbox Code Playgroud)
Zor*_*che 25
作为一个 puppet 用户,我解决这个问题的方法实际上是让我的 puppet 服务器收集我的 SSH 主机密钥并将它们发布到我所有建立 SSH 连接的系统。
这样我就不必担心删除它们。因为我的代理每 30 分钟运行一次,所以 puppet 有 99% 的时间为我运行并更新了密钥。我的例外情况非常罕见,因此如果我不愿意等待,我不介意快速编辑系统范围内的 known_hosts。
class ssh::hostkeys {
@@sshkey { "${::clientcert}_rsa":
type => rsa,
key => $sshrsakey,
tag => 'rsa_key',
}
if 'true' == $common::params::sshclient {
Sshkey <<| tag == 'rsa_key' |>> {
ensure => present
}
}
file {'/etc/ssh/ssh_known_hosts':
ensure => present,
owner => 'root',
group => 'root',
mode => 0644,
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7334 次 |
最近记录: |