解决Github REMOTE HOST IDENTIFICATION问题

问题描述

在使用Github过程中遇到了REMOTE HOST IDENTIFICATION问题,我是的环境是Windows系统+AndroidStudio,并且把github集成了到AST中,在AST中使用git push命令时出现了该错误,详细如下:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:xxx(这里显示当前的sSh key)
Please contact your system administrator.
Add correct host key in /c/Users/Administrator/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/Administrator/.ssh/known_hosts:1
RSA 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.

解决方法

我开始以为是ssh key过期了,登录到网页版的Github上查看后发现ssh key正常,那原因就是本地的ssh key出现异常了。
网上搜索到的解决方法都是在终端中输入以下命令:

ssh-keygen -R 服务器的IP

这个对于公司的git服务器显然可以这样做,我目前无法执行此操作,因为无法得到github的服务器ip.

我的解决方法:
按照提示内容,打开/c/Users/Administrator/.ssh/known_hosts文件,把该文件中与github相关的内容删除

github.com, xxx.xxx.xxx.xxx(ip) ssh-rsa xxx(ssh key) ==>删除此行内容
xxx.xxx.xxx.xxx(ip) ssh-rsa xxx(ssh key) ==>保留其它ip匹配的ssh key

此时再在AST中运行git push命令,会弹出一个"SSH confirmation"的提示窗口,选择yes就可以。该窗口的内容如下:
在这里插入图片描述
在这里插入图片描述

在这两张图片中间会显示新生成的ssh key,我剪切了此内容 。可以把两张图片合并后当作一图片使用。这个命令相当于是让git程序自动生成ssk key.

原因分析

在连接git管理的代码版本服务器时,ssh会把服务器的ssh key(public key)记录在know_hosts文件中,当下次再访问相同的服务器时ssh会检查该ssh key是否和服务器上的key相同,如果相同那么连接服务器;如果不同就发生警告并且阻止连接服务器。这个警告就是我在开始列出的信息。

通常使用ssh key认证的连接都会遇到此类问题,解决思路就是删除旧的ssh key,重新生成与服务器一致的ssh key.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

talk_8

真诚赞赏,手有余香

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

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

打赏作者

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

抵扣说明:

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

余额充值