【Github】生成SSH公钥 / The authenticity of host ‘github.com (192.30.xxx.113)‘ can‘t be established...

一. 场景再现

  • 此时我在新公司用 内网 IP 登录 Github,想要上传项目文件
  • git init,git add .,git status,git commit -m "xx",git push -u origin master,上面一通操作下来之后,报错了 QAQ


  • 报错信息:
  • The authenticity of host 'github.com (192.30.xxx.113)' can't be established.
  • RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
  • Are you sure you want to continue connecting (yes/no/[fingerprint])?

  • 输入 yes 一般可以解决问题

  • 如果输入 yes 没用,可能会出现新的报错
  • 报错信息:
  • Warning: Permanently added 'gitee.com,192.30.xxx.113' (ECDSA) to the list of known hosts.
  • Please make sure you have the correct access rights and the repository exists ...
  • 表示 ssh公钥 有问题,重新生成 ssh公钥 即可

  • 如果没有输入 yes,而是输入回车,可能会出现新的报错
  • 报错信息:
  • Host key verification failed.
  • fatal: Could not read from remote repository
  • 表示缺少:known_host 文件(位于 .ssh 文件夹)

  • 总结:一般 github / gitlab 在新的环境里,都需要配置 ssh

二. 生成 ssh公钥 过程

  • ① 删除 .ssh(查看位置: ll -d ~/.ssh)文件夹下的 known_hosts 文件(手动删除即可)

  • ② 执行 git 命令:$ ssh-keygen -t rsa -C "your@email.com"
  • 出现如下提示,一直 回车 就行:
  • Generating public/private rsa key pair.
  • Enter file in which to save the key (/Users/your_user_directory/.ssh/id_rsa):

  • ③ 系统会在 .ssh文件夹 下生成两个文件:id_rsa 和 id_rsa.pub,用 记事本 打开 id_rsa.pub ,并复制内容

  • ④ 登录自己的 Github,找到设置,将 上述内容 添加进来即可,如下:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Lyrelion

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值