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

相关推荐
星浩AI7 小时前
接手 20 万行代码从哪读起?Understand-Anything 把仓库变成可探索的知识图谱
后端·github·claude
用户480261584707 小时前
s3fs:用操作本地文件的方式读写 S3
github
Menahem7 小时前
解决 SSH 报错:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
运维·ssh·github
蔡不菜和他的uU们9 小时前
vLLM实践之个人AI基建——云端vLLM+SSH Tunnel+本地Cherry Studio
人工智能·ssh·vllm
2601_955781989 小时前
私有化本地 AI,Windows 平台 OpenClaw 功能详解与配置
人工智能·开源·github·open claw
云樱梦海10 小时前
OpenClaw官方:OpenClaw Windows Node 实战(1.5K ★ 开源推荐)
windows·开源·github·openclaw
CoderJia程序员甲11 小时前
GitHub 热榜项目 - 周榜(2026-06-06)
ai·大模型·llm·github
Harvy_没救了11 小时前
【github爆款】Headroom:AI代理的智能上下文压缩层 —— 深度解析与洞察
人工智能·github
DogDaoDao14 小时前
【GitHub】CodeGraph 深度解析:为 AI 编程代理构建预索引代码知识图谱
人工智能·程序员·github·知识图谱·ai编程·ai agent·codegraph
疋瓞14 小时前
G内使用github实践方式
github