sign_and_send_pubkey signing failed for RSA“/home/g/.ssh/id_rsa“ from agent: agent refused operation

在一个新的Linux环境下使用之前在其他机器上已经生成的id_rsa和id_rsa.pub文件连github报错:

The authenticity of host 'github.com (20.205.243.166)' can't be established.

...
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
sign_and_send_pubkey: signing failed for RSA "/home/g/.ssh/id_rsa" from agent: agent refused operation
git@github.com: Permission denied (publickey).
fatal: 无法读取远程仓库。

使用的id_rsa和id_rsa.pub本来是可以用来正常访问github的,在github上个人的账号里也设置了对应的key,怎么在新机器环境下就不行了呢?查看网上别人说的解决办法,出这种错误后,一般人都是重新创建公私钥配置了一遍,这不是我想要的解决办法,但又不知道为何不让访问,感觉上面的Permission denied错误提示说的不明不白的。

无意中随便试着执行了一下:

  ssh-add ~/.ssh/id_rsa

发现报的错给出了准确的原因:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0775 for '/home/g/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.

原来是文件的权限太多了,执行一下chmod 100 /home/g/.ssh/id_rsa只授予read权限,然后再执行

ssh-add ~/.ssh/id_rsa

就不报错了,然后用git clone git@github.com:/...方式下载代码都正常了

记录一下以防忘记后面再遇到浪费时间去查这个问题。

  • 9
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Arnold-FY-Chen

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值