今天在git提交远程仓库的时候,出现下面这错误信息
E:\Workspaces\IdeaProjects\permission>git push -u origin master
The authenticity of host 'gitee.com (120.55.226.24)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': y
Please type 'yes' or 'no': yes
Warning: Permanently added 'gitee.com' (ECDSA) to the list of known hosts.
Authentication failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
百度后,有这两种解释:
一、少了一个known_hosts文件,本来密钥文件应该是三个,现在是两个,便报了这样的错误,此时选择yes回车之后,便可,同时生成了缺少了的known_hosts文件
可yes 执行后,仍没有作用
二、这个原因可能是本地主机的key发生了变化,因此每次SSH链接都会有提示,只需要在交互下输入yes即可。
当然如果长久的想解决问题,可以采用以下方法:
1、使用ssh连接远程主机时加上“-o StrictHostKeyChecking=no”的选项,去掉对主机的验证检查。
ssh -o StrictHostKeyChecking=no 192.168.xxx.xxx
注:192.168.xxx.xxx 为本地ip地址:windows ipconfig查看,linux ifconfig查看
2、当然你也可以直接改配置文件信息,这样彻底去掉验证。
修改/etc/ssh/ssh_config文件(或$HOME/.ssh/config)中的配置,添加如下两行配置:
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
注:不过采用第二种方法,容易造成潜在的危险。可以参考Stackoverflow上的题:
ssh: The authenticity of host ‘hostname’ can’t be established
版权声明:本文为Wing_93原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。