ssh -T git@github.com 出现异常

上传代码到github 私有仓库

步骤

1. 生成 SSH Key(如果没有)

打开终端并运行:

bash

复制

复制代码
ssh-keygen -t ed25519 -C "your_email@example.com"
  • 按提示保存密钥文件和设置密码短语(可选)。
  • 默认位置是 ~/.ssh/id_ed25519
2. 添加 SSH Key 到 GitHub
  • 复制公钥内容:

    bash
    复制

    复制代码
    cat ~/.ssh/id_ed25519.pub
  • 登录 GitHub,进入个人设置。

  • 选择 "SSH and GPG keys",点击 "New SSH key"。

  • 粘贴公钥,添加标题,然后保存。

按照上面之下 测试 ssh -T -v git@github.com

出现:

复制代码

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ 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 RSA key sent by the remote host is

SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.

Please contact your system administrator.

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

Offending RSA key in /Users/zhuchuanshun/.ssh/known_hosts:10

Host key for github.com has changed and you have requested strict checking.

解决:

出现这个问题是因为 GitHub 的主机密钥已更改,需要更新你的 known_hosts 文件。可以按照以下步骤解决:

解决步骤

  1. 备份当前 known_hosts 文件

    bash
    复制

    复制代码
    cp ~/.ssh/known_hosts ~/.ssh/known_hosts_backup
  2. 删除旧的 GitHub 主机密钥

    找到并删除与 GitHub 相关的行。可以使用 ssh-keygen 命令:

    bash
    复制

    复制代码
    ssh-keygen -R github.com
  3. 获取并添加新的 GitHub 主机密钥

    尝试连接 GitHub,这将自动添加新的主机密钥:

    bash
    复制

    复制代码
    ssh -T git@github.com

    你会看到提示,询问是否信任新的主机密钥,输入 yes

  4. 验证连接

    再次测试 SSH 连接:

    bash
    复制

    复制代码
    ssh -T git@github.com

    如果看到欢迎消息,说明问题已解决。

相关推荐
cen__y8 小时前
Linux12(Git01)
linux·运维·服务器·c语言·开发语言·git
海蓝可知天湛9 小时前
Agent&IELTS雅思口语专属语料库
人工智能·github·rag·ielts·skills
ServBay10 小时前
OpenCode 和它的7款必备插件
后端·github·ai编程
Yunzenn10 小时前
字节最新研究cola-DLM第 01 章:语言生成的三次范式之争 —— 从 RNN 到 AR 到扩散
架构·github
wangruofeng11 小时前
GitHub AI 月榜解读:8 大趋势告诉你该关注什么
github·ai编程
bukeyiwanshui11 小时前
20260518 Swift实验
git·swift
qziovv11 小时前
Git 回退场景
大数据·git·elasticsearch
小小测试开发13 小时前
AI 水印攻防战:OpenAI 引入 SynthID 认证,GitHub 同步出现去水印工具
人工智能·github
来自大山深处的Doge_14 小时前
解决Git提交更新更改时出错: detected dubious ownership in repository at ...
git
微软技术栈15 小时前
Microsoft AI Genius 4.0 | 使用 GitHub Copilot SDK 升级开发者体验
人工智能·microsoft·github