2017-08-29 70 views
0

我已经设置了Github的密钥访问权限。当我从Git Bash命令行推送时,一切正常。但是我不能在命令行中使用它。当我做一个SSH -T [email protected]的命令行,它说不能从命令行推送到Github

Permission denied (publickey). 

如果我做一个混帐推说

Permission denied (publickey). 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

我知道钥匙是正确的,仓库存在,因为它从git bash中正常工作。有任何想法吗?

+1

您要么没有运行SSH代理,要么代理不知道您的SSH密钥。 –

+0

可能重复[Git - 权限被拒绝(publickey)](https://stackoverflow.com/questions/2643502/git-permission-denied-publickey) – phd

回答

1

这可能是两个原因之一:1.您没有设置SSH密钥,您必须从git获取SSH密钥或SSH密钥未链接到您的帐户。我会建议你尝试git HTTPS格式而不是SSH

帮助这里: https://help.github.com/articles/connecting-to-github-with-ssh/

而且还有即使你的问题github上页:https://help.github.com/articles/error-permission-denied-publickey/

+0

谢谢。我已经正确设置了密钥,如果不是,它不会与Git Bash正常工作? HTTPS是我通常使用的,但我不喜欢总是输入用户名和密码。我知道凭证可以存储,但我不喜欢这样做。我想从我的Windows命令行推荐使用它。 –

0

入住终端,SSH代理是否正在运行与否,使用下面的命令: -

eval "$(ssh-agent -s)",如果它没有运行,这似乎是问题。然后使用ssh-add ~/.ssh/id_rsa将您的私钥添加到ssh-agent,其中id_rsa是您的私钥。

将您的私钥添加到ssh-agent后,验证其是否已成功添加或使用ssh-add -l命令。