git 权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic) [英] git Permission denied (publickey,gssapi-keyex,gssapi-with-mic)
问题描述
我有一个公钥/私钥 rsa 密钥对.我可以使用 ssh 连接到远程服务器,但是当我执行 git pull origin master
时出现此错误:
I have a public/private rsa key pair. I can connect to remote server with ssh, but when I do git pull origin master
I get this error:
权限被拒绝(publickey、gssapi-keyex、gssapi-with-mic).致命的:无法从远程存储库读取.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic). fatal: Could not read from remote repository.
请确保您拥有正确的访问权限和存储库存在.
Please make sure you have the correct access rights and the repository exists.
我的 git 客户端运行 ubuntu 14.04
,我的公钥在文件夹 $HOME.ssh
中.
My git client run ubuntu 14.04
and my public private key is in the folder $HOME.ssh
.
我尝试了 sudo chmod -R 777 folder
但没有成功.
I tried to do sudo chmod -R 777 folder
but without any success.
推荐答案
sudo chmod -R 777 文件夹但没有任何成功.
sudo chmod -R 777 folder but without any success.
那是行不通的,因为任何写入权限的文件夹都会使 ssh 立即失败.
That would never work, as any folder with writing right would make ssh fail immediately.
您需要确保:
您已正确生成 ssh 密钥对:
you have generate the ssh key pair properly:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
(我建议不要一开始就设置密码,至少是为了测试)
(I recommend not setting a passphrase at first, at least for testing)
与您的 ~/.ssh/id_rsa(.pub) 的正确关联是正确的.
至少:
the right associate with your ~/.ssh/id_rsa(.pub) are correct.
At least:
chmod 700 /home/<login>/.ssh
chmod 600 /home/<login>/.ssh/authorized_keys
ssh url 是正确的.
例如,GitHub 将使用 git@github.com:user/repo
the ssh url is correct.
For instance, GitHub would use git@github.com:user/repo
您的 ssh 密钥已注册到您的帐户 (GitHub 示例)
your ssh key is registered to your account (Example for GitHub)
这篇关于git 权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!