git - 无法使用可用的 ssh-key 推送到 github

标签 git github push

这段代码:

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/

相关文章:

git - .gitignore 排除目录中的文件但不排除某些目录

ruby-on-rails - Heroku、Rails 和 ActiveUUID——Heroku 使用旧的迁移文件?

push-notification - 传入 Apple 推送通知的端口号

git - 如何在用户启动脚本中运行 git pull 并绕过 SSH 密码提示?

git - 警告 : this script is deprecated, 请参阅 git-completion.zsh

git - Visual Studio 2017 15.3.0 git 更改包括 "storage.ide",即使 .vs/in .gitignore

github - 无法连接到 GitHub API

Git:如何 rebase 一个裸仓库

iphone - 是否可以在 IOS 上第二次请求推送通知?

git - 推送 android studio 时删除 "remember password"