设置 SSH 密钥的初学者问题

发布于 2024-07-13 22:17:52 字数 391 浏览 6 评论 0原文

我收到此错误

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

错误消息的其余部分与此处类似。

我的服务器中有 SSH 密钥。 我的私钥在我的桌面上。 我不知道应该把它放在哪里。

Add correct host key in ~/Users/Sam/.ssh/known_hosts to get rid of this message.

我应该将服务器的公钥添加到文件中吗?

I get this error

WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED

The rest of the error message is similar to here.

I have SSH keys in my server. I have my private key in my desktop. I am not sure where I should put it.

Add correct host key in ~/Users/Sam/.ssh/known_hosts to get rid of this message.

Should I add the public key of my server to the file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

朕就是辣么酷 2024-07-20 22:17:52

问题在于,服务器的公钥与客户端上次连接时使用的公钥相比已发生变化,这可能表明有人试图欺骗您连接到以某种方式伪装成您的预期目标的服务器,以便窃取您的凭据或其他一些恶意行为。

如果服务器上的公钥已被显式更改,该消息也会自然出现,这可能出于多种合法原因而发生 - 不久前基于 Debian 的 Linux 发行版中的一个漏洞导致许多人需要重新生成密钥,例如。

如果您可以确认您正在连接到预期的目的地,并且您知道任何密钥更改都是合法的,那么您通常可以接受密钥更改。 或者,正如消息所解释的,您可以通过替代(安全)通道获取服务器的公钥并更新客户端的本地副本,以便它再次识别服务器的凭据。

如果您不控制服务器,请联系控制服务器的个人或组织,并查明更改是否合法。

不需要以任何方式修改您的私钥; 这与您的密钥对无关。

The issue is that the server's public key has changed from the one used the last time your client connected, and it may be indicative of an attempt to fool you into connecting to a server that's masquerading as your intended target in some fashion, in order to steal your credentials or some other malicious behaviour.

The message also naturally occurs if the public key on the server has been explicitly changed, which can happen for a number of legitimate reasons - a vulnerability in Debian-based Linux distributions in the not-so-distant past necessitated key regeneration for many people, for example.

If you can confirm that you're connecting to the intended destination, and you know that any key change was legitimate, then you can usually accept the key change. Alternatively, as the message explains, you can obtain the server's public key via an alternative (secure) channel and update your client's local copy so it recognises the server's credentials once more.

If you don't control the server, contact the person or organisation that does, and find out whether the change was legitimate.

You don't need to modify your private key in any way; this is nothing to do with your key pair.

薯片软お妹 2024-07-20 22:17:52

如果服务器上的密钥确实发生了更改(即您不是中间人攻击的受害者),最简单的想法是从消息中获取行号(违规密钥位于path/known_host:line_number),删除此行,登录服务器(并接受密钥)。

If the keys were really changed on the server (ie. you are not a victim of a man-in-the-middle attack), the easiest think to do is get the line number from the message (offending key is in path/known_host:line_number), delete this line, login to the server (and accept the key).

美男兮 2024-07-20 22:17:52

你的意思是,以编程方式?

也许您可以在此问题中发布的论坛中找到更好的支持:

https://stackoverflow.com/questions/321618

You mean, programatically?

Probably you can find better support at the forums posted in this question:

https://stackoverflow.com/questions/321618

澉约 2024-07-20 22:17:52

我只是遇到了这个错误,我认为这是因为我之前在我的笔记本电脑上使用另一个 Vagrant 实例来完成我的工作任务,现在该任务已经完成,我正在尝试将 Vagrant 用于我自己的项目,但是旧 Vagrant 实例的公钥仍在我的 known_hosts 文件中。 因此,我只是删除了 known_hosts 文件中 127.0.0.1 的旧条目并保存了该文件,错误就消失了。

I was just having this error and I think it's because I'd been previously using another Vagrant instance on my laptop for a work assignment I had, and now that that assignment has finished I'm trying to use Vagrant for my own project, but the old Vagrant instance's public key was still in my known_hosts file. So I just deleted the old entry in the known_hosts file for 127.0.0.1 and saved the file and the error went away.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文