[英]GitHub SSH access not working
I have created a new user on github under our organization which will be used for auto deployment.我在我们组织下的 github 上创建了一个新用户,用于自动部署。 I followed the article on https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#platform-linux .
我关注了https://help.github.com/articles/generate-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#platform-linux上的文章。
Somehow, when I tried to clone the repository to the server, it worked once.不知何故,当我尝试将存储库克隆到服务器时,它工作了一次。 The code was running properly, and I exit the server.
代码运行正常,我退出了服务器。 Today, we released an update to the code, and I wanted to deploy the code manually to the server, so I ssh'd into the server and tried to pull the repository with
git pull
.今天,我们发布了代码更新,我想手动将代码部署到服务器,所以我 ssh 进入服务器并尝试使用
git pull
拉取存储库。 It gave me Permission denied error.它给了我Permission denied错误。 After some debugging I realized that the ssh-agent wasn't running.
经过一些调试后,我意识到 ssh-agent 没有运行。 So I executed the following commands:
所以我执行了以下命令:
eval "$(ssh-agent -s)"
ssh-add .ssh/id_rsa_staging
Now, when I try ssh -T git@github.com
, I see the welcome message which is:现在,当我尝试
ssh -T git@github.com
,我看到欢迎消息是:
Hi *****! You've successfully authenticated, but GitHub does not provide shell access.
But when I try to pull from the repository, I am continuously getting this error message:但是当我尝试从存储库中提取时,我不断收到此错误消息:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I checked the repository and the user has read access to it.我检查了存储库,并且用户对其具有读取权限。 I double checked if the keys match on github and server, yes they do.
我仔细检查了 github 和服务器上的密钥是否匹配,是的。 I tried generating new keys.
我尝试生成新密钥。 I tried using ssh/config file.
我尝试使用 ssh/config 文件。 Nothing helped...
没有任何帮助...
I appreciate any help & suggestions!我感谢任何帮助和建议!
Update:更新:
So I figured out that git clone
command is working properly, but even when I try git pull
right after git clone, it is giving the error.所以我发现
git clone
命令工作正常,但即使我在 git clone 之后立即尝试git pull
,它也会给出错误。
If you are using sudo
to git pull/push
to the remote you need to ensure you used sudo
to generate your SSH keys.如果您使用
sudo
git pull/push
到远程,您需要确保使用sudo
生成您的 SSH 密钥。 Otherwise you will not be using the same keys that you originally generated.否则,您将不会使用最初生成的相同密钥。
I had the exact same issue.我有完全相同的问题。 For me what worked was
对我来说有效的是
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.