Wyg*_*eak 46 git permissions key public denied
GIT:我正在尝试将文件推送到朋友的回购,但公钥上有错误.
git push origin testbranch
Permission denied (publickey).
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
我们在哪里以及如何定义公钥/私钥?
git remote -v返回:
origin git@github.com:Sesamzaad/NET.git (fetch)
origin git@github.com:Sesamzaad/NET.git (push)
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏.
小智 78
我遇到了同样的问题,这就是我所做的对我有用的事情.
使用ssh而不是http.如果它的http删除原点.
git remote rm origin
Run Code Online (Sandbox Code Playgroud)
添加ssh网址
git remote add origin git@github.com:<username>/<repo>.git
Run Code Online (Sandbox Code Playgroud)
在.ssh /文件夹中生成ssh密钥.它会询问路径和密码,您只需按Enter键即可继续.
cd ~/.ssh
ssh-keygen
Run Code Online (Sandbox Code Playgroud)
复制密钥.您可以使用查看密钥.如果您没有指定其他路径,那么这是默认路径.
cat ~/.ssh/id_rsa.pub
Run Code Online (Sandbox Code Playgroud)
将此密钥添加到您的github帐户.接下来呢
ssh -T git@github.com
Run Code Online (Sandbox Code Playgroud)
您将在控制台中收到欢迎消息.
进入你的项目文件夹.git push -u origin master现在有效!
Ben*_* G. 14
我通过将密钥重新添加到我的 ssh-agent 来修复它。
使用以下命令:
ssh-add ~/.ssh/path_to_private_key_you_generated
由于某些原因它消失了。
小智 12
这对我有用.
首先,删除当前的远程:
git remote rm origin
Run Code Online (Sandbox Code Playgroud)
第二,通过HTTPS添加远程,但git @ xxx:
git remote add origin https://github.com/Sesamzaad/NET.git
Run Code Online (Sandbox Code Playgroud)
然后推送对我有用:
git push origin master
Run Code Online (Sandbox Code Playgroud)
小智 9
我正在运行Ubuntu 16.04
使用删除远程源
git remote rm origin
Run Code Online (Sandbox Code Playgroud)
使用设置http网址
git remote add origin https://github.com/<<Entire Path of the new Repo>>
git push origin master
Run Code Online (Sandbox Code Playgroud)
以上步骤已成功将代码添加到仓库中。
这对我有用。迄今为止最简单的解决方案。
如果您使用 Windows 版 GitHub 并收到此错误,问题可能是您尝试在错误的 shell 或模式下运行命令。如果您尝试git push origin master在常规命令提示符或PowerShell中执行操作,这就是问题所在。
您需要在git shell中执行此操作。只需打开 Windows 版 Github,右键单击,然后选择“在此处打开 Shell”。它看起来像一个常规的 PowerShell 窗口,但事实并非如此,这使得像我这样的新手对 git 感到非常困惑。
我希望其他人觉得这很有用。
小智 5
上述解决方案均不适合我.对于上下文,我正在运行ubuntu,我已经完成了ssh-key安装文档.我的解决方法是ssh-add在终端上运行.这解决了这个问题.
资料来源:http://baptiste-wicht.com/posts/2010/07/tip-how-to-solve-agent-admitted-failure-to-sign-using-the-key-error.html
小智 5
Github 上的文档非常有解释性。
https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account https://help.github.com/en/articles/generate-a-new -ssh 密钥并将其添加到 ssh 代理
我认为您必须执行指南中的最后步骤才能正确配置您的密钥
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
Run Code Online (Sandbox Code Playgroud)
您可能必须将公钥添加到 github。https://help.github.com/articles/generate-ssh-keys
检查此线程:GitHub:权限被拒绝(公钥)。fatal:远端意外挂断