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 [email protected]: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

[email protected]: 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 [email protected]

sign_and_send_pubkey: signing failed: agent refused operation

[email protected]: Permission denied (publickey).

还是失败

然后执行:

eval "(ssh-agent -k)"

SSH_AGENT_PID not set, cannot kill agent

eval "(ssh-agent -s)"

Agent pid 35072

然后执行:

$ ssh -T [email protected]

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

@ 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

[email protected]: Permission denied (publickey).

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

$ chmod 600 id*

$ chmod 644 k*

然后执行:

$ ssh -T [email protected]

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

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

相关推荐
问~4 小时前
gitea本地部署代码托管后仓库的新建与使用(配置好ssh密钥后仍然无法正常克隆仓库是什么原因)
运维·ssh·gitea
ZKf30FkG4 小时前
在 CentOS 7.9 中 Node 18.20.2 安装指南
linux·运维·centos
Virgocloud4 小时前
Centos更换镜像源-腾讯云镜像源
linux·centos·腾讯云
魂尾ac4 小时前
VMware Workstation Pro下Centos 7.9 安装
linux·运维·centos
31535669137 小时前
我开源了一套springboot3快速开发模板
后端·github
阿尔法和贝塔8 小时前
我是如何搭建这个博客的:与Zola、GitHub和一个AI结对程序员的旅程
github·openai
暴走的YH8 小时前
linux无网络环境下离线安装依赖包
linux·服务器·centos
老白码农在奋斗15 小时前
GitHub每周热点(20250620)
github
清风细雨_林木木15 小时前
GitHub Copilot 配置快捷键
github·copilot