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

相关推荐
Arthurmoo1 小时前
Linux系统集群部署模块之Keepalived双机热备
linux·git·github
longerxin20203 小时前
在 CentOS 8 上彻底卸载 Kubernetes(k8s)
linux·kubernetes·centos
Zik----3 小时前
github上传大文件(多种解决方案)
深度学习·github
听风者6776 小时前
github和码云使用同一个公钥和分开使用
github
独立开阀者_FwtCoder8 小时前
前端大一统时代来了
前端·vue.js·github
测试开发技术9 小时前
git rm 命令与系统的 rm 命令有什么区别?
git·gitlab·github·面试题
zcg194210 小时前
工作第一步建立连接——ssh
运维·服务器·ssh
落落鱼201310 小时前
CentOS服务器安装Supervisor使队列可以在后台运行
linux·服务器·centos·队列
longze_710 小时前
Jenkins credentials 增加了github credential 但是在Git SCM 凭证中不显示
git·github·jenkins
seth10 小时前
coding 要停服了, 把所有 CI 迁移到 Github 上 (服务器无需翻墙)
ci/cd·docker·github