---
title: "macOS 终端远程连接密钥验证失败 - 一纸忘忧"
description: "以前在 Windows 下远程连接 Linux 服务器一般用的是 PuTTY，现在换到 macOS 了，发现 macOS 系统自带的终端也是具有远程连接功能的，不需要下载其他的 SSH 客户端。"
canonical_url: "https://www.ikxin.com/article/macos-ssh-key-failure"
last_updated: "2026-09-16T09:59:27.259Z"
locale: zh-cn
meta:
  "og:description": "以前在 Windows 下远程连接 Linux 服务器一般用的是 PuTTY，现在换到 macOS 了，发现 macOS 系统自带的终端也是具有远程连接功能的，不需要下载其他的 SSH 客户端。"
  "og:image": "https://www.ikxin.com/_og/d/h_630%2Ca_~bWFjT1Mg57uI56uv6L-c56iL6L-e5o6l5a-G6ZKl6aqM6K-B5aSx6LSlIC0g5LiA57q45b-Y5b-n%2Cc_Article%2Ctitle_~bWFjT1Mg57uI56uv6L-c56iL6L-e5o6l5a-G6ZKl6aqM6K-B5aSx6LSl%2Cdescription_~5Lul5YmN5ZyoIFdpbmRvd3Mg5LiL6L-c56iL6L-e5o6lIExpbnV4IOacjeWKoeWZqOS4gOiIrOeUqOeahOaYryBQdVRUWe-8jOeOsOWcqOaNouWIsCBtYWNPUyDkuobvvIzlj5HnjrAgbWFjT1Mg57O757uf6Ieq5bim55qE57uI56uv5Lmf5piv5YW35pyJ6L-c56iL6L-e5o6l5Yqf6IO955qE77yM5LiN6ZyA6KaB5LiL6L295YW25LuW55qEIFNTSCDlrqLmiLfnq6~jgII%2CsiteName_~5LiA57q45b-Y5b-n%2CsiteHost_www.ikxin.com%2Cp_Ii9hcnRpY2xlL21hY29zLXNzaC1rZXktZmFpbHVyZSI%2Cs_oP-Qa2J241dnzMaq.png"
  "og:image:alt": "macOS 终端远程连接密钥验证失败 - 一纸忘忧"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "macOS 终端远程连接密钥验证失败"
  "twitter:image": "https://www.ikxin.com/_og/d/h_630%2Ca_~bWFjT1Mg57uI56uv6L-c56iL6L-e5o6l5a-G6ZKl6aqM6K-B5aSx6LSlIC0g5LiA57q45b-Y5b-n%2Cc_Article%2Ctitle_~bWFjT1Mg57uI56uv6L-c56iL6L-e5o6l5a-G6ZKl6aqM6K-B5aSx6LSl%2Cdescription_~5Lul5YmN5ZyoIFdpbmRvd3Mg5LiL6L-c56iL6L-e5o6lIExpbnV4IOacjeWKoeWZqOS4gOiIrOeUqOeahOaYryBQdVRUWe-8jOeOsOWcqOaNouWIsCBtYWNPUyDkuobvvIzlj5HnjrAgbWFjT1Mg57O757uf6Ieq5bim55qE57uI56uv5Lmf5piv5YW35pyJ6L-c56iL6L-e5o6l5Yqf6IO955qE77yM5LiN6ZyA6KaB5LiL6L295YW25LuW55qEIFNTSCDlrqLmiLfnq6~jgII%2CsiteName_~5LiA57q45b-Y5b-n%2CsiteHost_www.ikxin.com%2Cp_Ii9hcnRpY2xlL21hY29zLXNzaC1rZXktZmFpbHVyZSI%2Cs_oP-Qa2J241dnzMaq.png"
  "twitter:image:alt": "macOS 终端远程连接密钥验证失败 - 一纸忘忧"
---

> Index of every page on this site: [llms.txt](https://www.ikxin.com/llms.txt)

# **macOS 终端远程连接密钥验证失败**

2019.07.20 6,394  0

以前在 Windows 下远程连接 Linux 服务器一般用的是 PuTTY，现在换到 macOS 了，发现 macOS 系统自带的终端也是具有远程连接功能的，不需要下载其他的 SSH 客户端。

然后我在一台洛杉矶的 VPS 上面装酸酸乳时，出了点问题然后重置系统，第二次连接 SSH 发现了报错：

 Plain Text

```
$ ssh root@107.174.218.121@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    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 ECDSA key sent by the remote host isSHA256:HDjXJvu0VYXWF+SKMZjSGn4FQmg/+w6eV9ljJvIXpx0.Please contact your system administrator.Add correct host key in /Users/ikxin/.ssh/known_hosts to get rid of this message.Offending ECDSA key in /Users/ikxin/.ssh/known_hosts:46ECDSA host key for 107.174.218.120 has changed and you have requested strict checking.Host key verification failed.
```

大致意思就是主机密钥校验失败，和第一次保存的密钥不一致。这个问题在使用 PuTTY 时并没有遇到过，可能是两者的机制不一样。出现这个问题一般是重置系统导致的，因为重置系统时会重新生成密钥，所以就匹配不上了。

解决问题也很简单，使用的是 `ssh-keygen`。

在终端输入：

 Plain Text

```
ssh-keygen -R 你要访问的 IP 地址
```

这样就可以重置这个 IP 的匹配密钥了，而且还会将旧的密钥保存在 `known_hosts.old` 文件中。

## **评论**

(0)

暂无评论，来说两句吧

## **发布评论**

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://www.ikxin.com/#website","@type":"WebSite","description":"一纸忘忧的个人网站，关于技术探索与日常生活，记录 Web 开发、服务端与 DevOps 实践，分享软件工具、数码体验，以及代码之外的见闻与思考。","inLanguage":"zh-CN","name":"一纸忘忧","url":"https://www.ikxin.com/","workTranslation":[{"@id":"https://www.ikxin.com/zh-tw#website"},{"@id":"https://www.ikxin.com/ko#website"},{"@id":"https://www.ikxin.com/en#website"},{"@id":"https://www.ikxin.com/ja#website"}]},{"@id":"https://www.ikxin.com/article/macos-ssh-key-failure#webpage","@type":"WebPage","description":"以前在 Windows 下远程连接 Linux 服务器一般用的是 PuTTY，现在换到 macOS 了，发现 macOS 系统自带的终端也是具有远程连接功能的，不需要下载其他的 SSH 客户端。","name":"macOS 终端远程连接密钥验证失败","url":"https://www.ikxin.com/article/macos-ssh-key-failure","isPartOf":{"@id":"https://www.ikxin.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://www.ikxin.com/article/macos-ssh-key-failure"]}]}]}
```

## Sitemap

See the full [sitemap](https://www.ikxin.com/sitemap.md) for all pages.
