这段代码:
sudo git push -u <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88efe1fcc8efe1fce0fdeaa6ebe7e5" rel="noreferrer noopener nofollow">[email protected]</a>:myusername/wolke master
给我这个错误:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
我检查了我的 ssh key 。和github中的一样。
如何检查存储库是否存在?我用 git init 初始化了一个存储库,所以它应该存在。
我还能做什么?
解决方案: 不要使用 sudo!
git push -u <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="492e203d092e203d213c2b672a2624" rel="noreferrer noopener nofollow">[email protected]</a>:myusername/wolke master
最佳答案
因为当您使用 sudo 时,git 以 root 身份运行,因此使用 root 的 ssh key 。如果没有 sudo,您将使用自己的 key ,因此一切都会按预期进行。
关于git - 无法使用可用的 ssh-key 推送到 github,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31490761/