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代理拒绝代理了。

相关推荐
Kakaa1 小时前
AI 帮我写了一万行代码,但我已经看不懂自己的项目了
github
Hy行者勇哥2 小时前
Coze技能保存至GitHub:文件格式与完整存档教程
github
Irene19912 小时前
两种 Linux 发行版:Ubuntu 与 CentOS Shell 环境核心差异对比(查看 Linux 版本,Hadoop 是什么)
linux·ubuntu·centos
gjc5922 小时前
Linux MySQL服务器SSH多端口配置:解决22端口禁直连,兼顾安全与运维
linux·运维·服务器·mysql·ssh
wanderist.2 小时前
完美解决VS Code/Cursor远程连接报错:远程主机不满足运行 VS Code 服务器的先决条件(附AI编程最佳实践)
运维·服务器·ssh·ai编程
weelinking2 小时前
2026年三大主流大模型深度对比:GPT-5.5、Claude 4.6与DeepSeek V4谁更值得选择?
java·大数据·人工智能·git·python·gpt·github
梦梦代码精3 小时前
开源智能体平台 BuildingAI 深度解析:Monorepo 架构、MCP 集成及 GPT-Image-2 接入实测
前端·人工智能·后端·gpt·开源·github
tedcloud1238 小时前
UI-TARS-desktop部署教程:构建AI桌面自动化系统
服务器·前端·人工智能·ui·自动化·github
wangruofeng12 小时前
为什么 build-your-own-x 能成为 GitHub Star 排名第一
github·ai编程
白鲸开源17 小时前
杀疯了!SeaTunnel AI CLI 解锁数据集成新玩法
大数据·人工智能·github