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 "xxx@example.com"

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

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

git clone ssh://xxx@git.example.cn: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://xxx@git.example.cn: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

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值