原创

github提交代码提示known_hosts无权限

1、报错信息

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/fengqingyang/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/fengqingyang/.ssh/known_hosts:1
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.

2、问题的原因

用OpenSSH的人都知ssh会把你每个你访问过计算机的公钥(public key)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告。

原因是我的GitLab服务器重装了系统(清除了与我本地SSH连接协议相关信息),本地的SSH协议信息便失效了。SSH连接相同的ip地址时因有连接记录直接使用失效的协议信息去验证该ip服务器,所以会报错,使用上述命令便可以清除known_hosts里旧缓存文件。

3、 解决方法

删除xxx.xxx.xxx.xxx (服务器ip地址)的相关rsa的信息即可

在本地机输入一下命令行:

ssh-keygen -R xxx.xxx.xxx.xxx (服务器ip地址)

ssh-keygen -R github.com
正文到此结束
本文目录