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

相关推荐
悲伤小伞13 分钟前
9-MySQL_索引
linux·数据库·c++·mysql·centos
赵文宇(温玉)17 分钟前
Openclaw-In-Docker新版本发布,更轻、更快、更健壮,1600+次下载,30+Github关注
docker·容器·github·小龙虾·clawclaw
CoderJia程序员甲18 分钟前
GitHub 热榜项目 - 日榜(2026-03-23)
ai·大模型·llm·github·ai教程
badhope38 分钟前
Docker入门到实战全攻略
linux·python·docker·github·matplotlib
麦芽糖02191 小时前
centos虚拟机忘记密码怎么办
linux·运维·centos
困死,根本不会1 小时前
树莓派 SSH 连接排错实录:从 IP 网段到主机密钥变更,再到 VNC 自启动
开发语言·ssh·php·树莓派
用户9751470751362 小时前
双向绑定VUE,单向绑定react区别
github
虎头金猫3 小时前
小米摄像头本地化存储教程:Go2RTC+EasyNVR 搭建私有监控系统
langchain·开源·github·aigc·智能家居·开源软件·ai编程
用户9751470751363 小时前
在 Vite 中配置 CSS 模块时,如何处理不同 CSS 模块之间的冲突?
github
汪海游龙4 小时前
03.24 AI 精选:2小时从零训练26M参数GPT的教学项目
github