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
相关推荐
M78佐菲11 分钟前
HTML学习笔记
linux·笔记·学习·tcp/ip·html
新时代牛马13 分钟前
嵌入式 Linux 蓝牙框架完整篇:从 HCI、L2CAP 到BlueZ 用户态
linux·运维·服务器
Brilliantwxx1 小时前
【STM32】 初认识USART串口
linux·stm32·单片机·嵌入式硬件·架构
aningx1 小时前
使用自定义bash脚本预防oom卡死
linux
麻辣布丁1 小时前
Git冲突原因与解决方法全解
大数据·git·elasticsearch
ONLYOFFICE1 小时前
ONLYOFFICE成为Linux操作系统 – Winux的预装办公套件
linux·运维·服务器
mounter6251 小时前
从内核安全到可编程基础设施:Meta 的 eBPF 实践与形式化验证探索
linux·ebpf·linux kernel·kernel
新时代牛马1 小时前
嵌入式 Linux WiFi 框架完整篇:从cfg80211、mac80211 到wpa_supplicant
linux·运维·服务器
吴声子夜歌2 小时前
Linux命令——打印
linux·运维·服务器
企鹅的蚂蚁2 小时前
Linux 开发板串口调试:picocom 从识别到退出的完整用法
linux·运维·服务器