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
相关推荐
赵庆明老师5 小时前
Vben精讲:04-了解VSCode中的Git
ide·git·vscode
Uncertainty!!7 小时前
Ubuntu 22.04 安装超好用中文输入法rime-ice(雾凇拼音)过程记录
linux·ubuntu·中文输入法
ShineWinsu8 小时前
对于Linux:网络基础的解析
linux·网络·面试·udp·笔试·ip·tcp
Asuicao8 小时前
centos7.9版本升级ssh OpenSSH 9.8p1 源码 OpenSSL 1.1.1w 源码包以及安装升级回滚文档
运维·ssh
↘"LYong9 小时前
旧版 CentOS 安装 Docker 完整指南(附国内镜像加速)
linux·运维·docker
Zhang~Ling9 小时前
Vim 多模式详解:命令、插入、底行与插件配置
linux·编辑器·vim
想你依然心痛11 小时前
Linux用户空间与内核空间通信:netlink、ioctl、mmap 零拷贝与性能对比
linux·运维·服务器
Irissgwe11 小时前
第 5 篇:Git 分支基础:branch、checkout、merge 和冲突解决
git
做个文艺程序员11 小时前
Linux第12篇:性能监控与瓶颈分析——CPU/内存/IO/网络全维度
linux·运维·网络
HAPPY酷12 小时前
【ROS2】 Conda 环境搭建(命令行版)
linux·运维·python·ubuntu·机器人·conda