GitHub Err (3)git push -u origin main报错

GitHub Err (3)git push -u origin main报错

0. 报错

$ git push -u origin main @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 /c/Users/dell/.ssh/known_hosts to get rid of this message. Offending RSA key in /c/Users/dell/.ssh/known_hosts:2 Host key for github.com has changed and you have requested strict checking. Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
notion image

1. 分析

  • 看这两行,原因是系统有改变,导致加密的密钥改变,因此本地保存的密钥失效
Add correct host key in /c/Users/dell/.ssh/known_hosts to get rid of this message. Offending RSA key in /c/Users/dell/.ssh/known_hosts:2

2. 解决

  • 删除c/Users/dell/.ssh/known_hosts:2 文件中指定ip的密钥即可,
  • 我这里提示的是删除第二行

2.1 生成密钥

在打开的窗口输入,设置user.name和user.email配置信息
git config --global user.name "你的GitHub用户名" git config --global user.email "你的GitHub注册邮箱"
git config --global user.name "genghenggao" git config --global user.email "genghenggao@outlook.com"
然后生成ssh密钥文件
ssh-keygen -t rsa -C "你的GitHub注册邮箱"
ssh-keygen -t rsa -C "genghenggao@outlook.com"
然后三个回车就可以了
然后在C:\Users\admin\.ssh文件夹中找到id_rsa.pub,将里面所有的内容全部复制出来。
notion image
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDmMRbLqxvZf60j9gOnhp3ngoxYmkilWwyBE3J2QQ2gSTfXgSbU/nTgk5BDZ7vmTatEE0MKAdioW5hGwx0xsQDqYBPNKAx/8TaqcaZxeOLROAkdw1L4vJiy5YNokzF25a33+10nanDT7QpTIj1Evi6z8CKiTxFaAV4CGndOpZbPkWTeFy/B6SaC0KnxsRZ9gThkGqwi1u/0Xy9SXGSM8tf5bZAqNB7/0DDiGDThPFzwjj9ZG1ueq7cEm0mHNCqNZqcDEUWiPSQNs5NlwuIrDA0OvuuwThRiuq0M7bM0qqtFxK3fm39eEjo57j/xcwNOxE1bFyy9+Q9YwsNrzfmtc/M+v7rHH1dSGYBPwe9cndRhWHMKK9Kxx3k4G9gaVFvUwnF721tLz4xwc04EpG1CM2ex6Mmbv54w2IBXGj2bQSxVmKBjf21h8v71kKw/ZjYJV15pREpSnf/FAOLNP9rQHRJeIsZIagnMGvp4txEr6df85y44IfCgLZpvqtsYpepyeVE= genghenggao@outlook.com
notion image
Title随便输入,Key粘贴刚才复制的key,然后点击Add SSH key
notion image
验证一下是否连接成功
在Git Bash中输入
ssh git@github.com
如果出现在Are you sure you want to continue connecting (yes/no[fingerprint])? 这里输入Yes就可以了
notion image
再次执行,显示下面这样就是成功了
notion image

3. 再次提交

notion image