git clone 出现 “Connection to gitee.com closed by remote host”错误
程序员文章站
2022-05-01 15:54:56
...
在执行git clone 命令的时候,出现了这个错误
$ git clone aaa@qq.com:didispace/SpringBoot-Learning.git
Cloning into 'SpringBoot-Learning'...
The authenticity of host 'gitee.com (116.211.167.14)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'gitee.com' (ECDSA) to the list of known hosts.
Connection to gitee.com closed by remote host.
fatal: Could not read from remote repository.
出现这个错误的原因是因为没有在git 或码云上面添加SSH key.
解决方法:
1、打开终端,输入
ssh-****** -t rsa -C "aaa@qq.com"
然后三次回车,即可生成
注意,aaa@qq.com是你在git上的用户名
2、查看你的 public key,并把他添加到码云(Gitee.com) SSH key添加地址:https://gitee.com/profile/sshkeys
cat ~/.ssh/id_rsa.pub
然后在码云上面添加
3、添加后,在终端(Terminal)中输入
ssh -T git@gitee.com
若返回
Welcome to Gitee.com, yourname!
则证明添加成功