git clone 出错:Permission denied (publickey).

网上找了好久的解决方案,全都试了一遍,结果还是不行=。=

今天又想弄一下了,毕竟老是用笔记本也不太方便。。。终于找到了一个有效的解决方案,已经成功了。

 

git clone ssh://xxx
正克隆到 'xxx'...
Warning: Permanently added '[git.xxx.cn]:29418,[xx.xx.xx.xx]:29418' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
 

刚开始找到一个解决方案,执行如下:

git remote remove origin

error: 不能移除配置小节 'remote.origin'    //莫名的错误。。。

ssh-add -D

All identities removed.

rm -r ~/.ssh

ssh-keygen -t rsa -C "[email protected]"

重新添加 cat ~/.ssh/id_rsa.pub 以后

再次执行git clone,仍然报错:

git clone ssh://[email protected]:29418/xxx
正克隆到 'xxx'...
The authenticity of host '[git.xxx.cn]:29418 ([xx.xx.xx.xx]:29418)' can't be established.
RSA key fingerprint is SHA256:xxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[git.xxx.cn]:29418,[xx.xx.xx.xx]:29418' (RSA) to the list of known hosts.
sign_and_send_pubkey: signing failed: agent refused operation
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

 

这次的错误多了一句sign_and_send_pubkey: signing failed: agent refused operation

于是百度之,找到了一个解决方案:https://www.cnblogs.com/ailhc/p/6586465.html

执行如下命令:

eval "$(ssh-agent -s)"

ssh-add

 

结果再次执行git clone 就成功了。。。

原理不懂。。。

 

 

 

git clone ssh://[email protected]:29418/xxx
正克隆到 'xxx'...
remote: Counting objects: xxx, done
remote: Finding sources: 100% (xxx/xxx)
remote: Total xxx (delta xxx), reused xxx (delta xxx)
接收对象中: 100% (xxx/xxx), xxx.xx MiB | xx.xx MiB/s, 完成.
处理 delta 中: 100% (xxx/xxx), 完成.
检查连接... 完成。
Warning: Permanently added the RSA host key for IP address '[xx.xx.xx.xx]:29418' to the list of known hosts.
commit-msg                                    100% xxx     xxKB/s   00:00

你可能感兴趣的:(git)