繁体   English   中英

无法从命令行推送到Github

[英]Cannot push to Github from command line

我可以访问Github的设置密钥。 当我从Git Bash命令行推送时,一切工作正常。 但是我不能从命令行使用它。 当我从命令行执行ssh -T git@github.com时,它说

Permission denied (publickey).

如果我做一个git push它说

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密钥,而您必须从git那里获得该密钥,或者SSH密钥未链接到您的帐户。 我建议您尝试使用git而不是SSHHTTPS格式。

此处的帮助: https : //help.github.com/articles/connecting-to-github-with-ssh/

甚至还有一个关于您问题的github页面: https : //help.github.com/articles/error-permission-denied-publickey/

使用以下命令检查终端中是否正在运行SSH代理:-

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM