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
相关推荐
尤老师FPGA5 小时前
petalinux修改设备树添加vdma生成linux系统
android·linux·运维
月山知了5 小时前
linux kernel component子系统:基于rk3588 Android 14 kernel-6.1 display-subsystem代码分析
android·linux·运维
_Emma_5 小时前
【QCOM】 Linux下qcom venus 编解码驱动框架分析
linux·驱动开发·视频编解码
徐健峰5 小时前
Claude Code 安装完全指南(Mac 版):Git、环境变量、PATH 与常见报错一次讲清(2026)
git·macos·arcgis
不才小强6 小时前
Linux系统常用命令
linux·运维·网络
sunriver20007 小时前
【Git】TortoiseGit无法push远程仓库
git·tortoisegit
SPC的存折7 小时前
8、Ansible之Playbook---Roles
linux·服务器·ansible
Kira Skyler7 小时前
BPF KPROBE编程中的ctx是什么?
linux
三万棵雪松9 小时前
【Linux 物联网网关主控系统-Linux主控部分(三)】
linux·物联网·嵌入式linux
萝卜白菜。9 小时前
TongWeb7.0 集中管理heimdall配置文件说明
linux·运维·服务器