Linux中Git推送报错Permissions 0644 for ‘/root/.ssh/id_rsa‘ are too open

准备在Linux上配置秘钥,方便Git上传代码到GitHub。

但是秘钥(id_rsa文件)是从本地Windows环境上传到Linux服务器上面的,在执行推送时报错了,如下:

shell 复制代码
# git push -u origin main
The authenticity of host 'github.com (20.205.243.166)' can't be established.
ECDSA key fingerprint is SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM.
ECDSA key fingerprint is MD5:7b:99:81:1e:4c:91:a5:0d:5a:2e:2e:80:13:3f:24:ca.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,20.205.243.166' (ECDSA) to the list of known hosts.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/root/.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.
Load key "/root/.ssh/id_rsa": bad permissions
Permission denied (publickey).
致命错误:无法读取远程仓库。

请确认您有正确的访问权限并且仓库存在。

很明显,意思是该文件权限太大了,然后被拒绝操作了。(其实我感觉有点奇怪,好像管的有点宽,权限够你操作不就行了吗?还不能太高......)

虽然知道了问题所在,但是不清楚具体要调成啥权限,搜了下关键字,发现600权限就够了。

shell 复制代码
chmod 600 /root/.ssh/id_rsa
相关推荐
平行云PVT2 小时前
数字孪生信创云渲染技术解析:从混合信创到全国产化架构
linux·unity·云原生·ue5·图形渲染·webgl·gpu算力
xdscode3 小时前
Linux云服务器安装openclaw,并对接飞书通道
linux·服务器·飞书·openclaw
Percep_gan3 小时前
Linux中安装Redis,很详细
linux·运维·redis
2401_877274244 小时前
从匿名管道到 Master-Slave 进程池:Linux 进程间通信深度实践
linux·服务器·c++
feng_you_ying_li4 小时前
linux之用户的权限详解(4)
linux·运维·服务器
vistaup5 小时前
windows git 更新当前目录下所有的文件(非递归)
windows·git
二进制person5 小时前
JavaEE初阶 --网络编程
linux·服务器·网络
Cyber4K6 小时前
【妙招系列】Harbor 镜像私有仓库搭建手册
linux·云原生·容器
王码码20356 小时前
Flutter for OpenHarmony:Flutter 三方库 algoliasearch 毫秒级云端搜索体验(云原生搜索引擎)
android·前端·git·flutter·搜索引擎·云原生·harmonyos
Irissgwe6 小时前
进程间通信
linux·服务器·网络·c++·进程间通信