CentOS 8解决ssh连接github时sign_and_send_pubkey失败问题

我在一台centos8机器上安装git环境以连接到github,首先第一步需配置好ssh环境,因为我已经有一台Ubuntu机器已经配置好ssh环境,所以我ftp Ubuntu机器取得id_rsa id_rsa.pub known_hosts三个文件,然后执行命令:

$ git clone git@github.com:your-username/learning_log.git

Cloning into 'learning_log'...

Warning: Permanently added the ECDSA host key for IP address '20.205.243.166' to the list of known hosts.

sign_and_send_pubkey: signing failed: agent refused operation

git@github.com: Permission denied (publickey).

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.

明显失败了

然后执行以下命令直接用ssh测试:

$ ssh -T git@github.com

sign_and_send_pubkey: signing failed: agent refused operation

git@github.com: Permission denied (publickey).

还是失败

然后执行:

eval "(ssh-agent -k)"

SSH_AGENT_PID not set, cannot kill agent

eval "(ssh-agent -s)"

Agent pid 35072

然后执行:

$ ssh -T git@github.com

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

@ WARNING: UNPROTECTED PRIVATE KEY FILE! @

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

Permissions 0664 for '/home/zhang/.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 "/home/zhang/.ssh/id_rsa": bad permissions

git@github.com: Permission denied (publickey).

毛病找到了,是密钥文件的权限问题。然后执行:

$ chmod 600 id*

$ chmod 644 k*

然后执行:

$ ssh -T git@github.com

Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.

问题总结:是因为我ftp Ubuntu机器get密钥文件到本地的时候权限变了,ssh代理拒绝代理了。

相关推荐
Sakura_j_h_4 小时前
EasyEDA PCB 快速设计Skills
c++·python·github
wflynn7 小时前
GitHub 今日推荐|Edge0:让大号 MoE 模型在一台 Mac 上流式跑起来
python·开源·github
用户别睡觉9 小时前
五大 RAG 开源项目对比 2026:Dify、RAGFlow、FastGPT、AnythingLLM、LightRAG
github
用户7273744138849 小时前
在 Windows 11 上从零装好 Carapace BIN:一次真实操作记录
github
是真的小外套10 小时前
网络安全实战第7期:Hydra爆破SSH实战
安全·web安全·ssh
miofly10 小时前
Claude Sonnet 5自主选药选坐标完成小鼠脑部手术,更强模型拒绝执行
开源·github
塞讯科技10 小时前
13,500 个分支被植入窃密工作流:Gheist 如何用 GitHub 令牌搬走仓库密钥
网络安全·ai·github·软件供应链安全·供应链投毒
阿智的AI开发笔记15 小时前
充了 200 块只跑出 3 条:AI 视频真正贵的地方,是「按次」和「按秒」的区别
github
GitHub实测笔记16 小时前
rtk 本机实测:给 AI Agent 砍掉 90% 的命令行噪音(Linux)
github
小莫46116 小时前
CI 全绿了,测试却可能是假的:GitHub Actions 三个静默失效的坑
github