git推送:权限被拒绝(公钥)
我正试图将一个文件推送到一个朋友的git repo,但公钥出错git推送:权限被拒绝(公钥),git,permissions,public-key,Git,Permissions,Public Key,我正试图将一个文件推送到一个朋友的git repo,但公钥出错 git push origin testbranch Permission denied (publickey). fatal: Could not read from remote repository. 我们在何处以及如何定义公钥/私钥 git remote-v返回: origin git@github.com:Sesamzaad/NET.git (fetch) origin git@github.com:Sesamzaa
git push origin testbranch
Permission denied (publickey).
fatal: Could not read from remote repository.
我们在何处以及如何定义公钥/私钥
git remote-v
返回:
origin git@github.com:Sesamzaad/NET.git (fetch)
origin git@github.com:Sesamzaad/NET.git (push)
非常感谢您的帮助。您可能需要将公钥添加到github
检查此线程:我也面临同样的问题,以下是我所做的工作 使用ssh而不是http。如果源代码是http,请删除它
git remote rm origin
添加ssh url
git remote add origin git@github.com:<username>/<repo>.git
复制钥匙。您可以使用查看密钥。如果没有指定其他路径,则这是默认路径
cat ~/.ssh/id_rsa.pub
将此密钥添加到您的github帐户。下一步
ssh -T git@github.com
您将在控制台中收到欢迎信息
将cd放入项目文件夹中
git-push-u原始主机
现在可以工作了 我不得不处理这个问题@user3445140的回答帮助了我,但远远超出了我需要做的
cat~/.SSH/id\u rsa.pub
如果您已经将公钥添加到GITHUB服务器,则可以尝试其他解决方案 在我的例子中,GIT推送在RUBYMINE内部失败,但在终端窗口中解决了问题 有关更多解决方案,请访问此页面
这对我很有效。迄今为止最简单的解决方案 如果您正在使用GitHub for Windows并出现此错误,则问题可能是您试图在错误的shell或模式下运行该命令。如果您试图在常规的命令提示符或PowerShell中执行
git push origin master
,这就是问题所在
您需要在git shell中执行此操作。只需打开Github for Windows,右键单击,然后选择“在此处打开Shell”。它看起来像是一个常规的PowerShell窗口,但它不是,这让像我这样的新手对git非常困惑
我希望其他人会觉得这很有用。上述解决方案都不适合我。在上下文中,我运行的是ubuntu,我已经阅读了ssh密钥设置文档。我的修复方法是在终端中运行
ssh add
。这解决了问题
来源:这对我很有效
首先,删除当前远程:
git remote rm origin
第二,通过HTTPS添加远程,但是git@xxx:
git remote add origin https://github.com/Sesamzaad/NET.git
那么push对我起作用了:
git push origin master
为了部署到朋友的repo,您需要将公钥添加到存储库的部署密钥中 转到存储库,转到部署密钥,并将id_rsa.pub(或您的任何名称)添加到“部署密钥” 我相信将密钥添加到您自己的帐户只会让您写入您的帐户创建的存储库。如果它是由组织创建的,则需要将密钥添加到repo的部署密钥中
我通过向ssh代理重新添加密钥来修复它 使用以下命令:
ssh将~/.ssh/path\u添加到您生成的私钥中
由于某些原因,它消失了。我正在运行Ubuntu 16.04 使用删除远程原点
git remote rm origin
使用设置http url
git remote add origin https://github.com/<<Entire Path of the new Repo>>
git push origin master
git远程添加源https://github.com/
git推送源主机
上述步骤成功地将代码添加到repo 我也遇到了同样的问题。请你的朋友通过转到他的repo设置并添加新的协作者,将你添加为协作者 你将收到一封邀请电子邮件,接受它。然后你就可以出发了。
只需确保您添加了正确的遥控器 在Windows上使用Ubuntu Bash时发生此错误 我切换到标准的windows cmd提示符,它没有出现错误
这是一个解决方法,因为这意味着如果您想使用ubuntu,您可能需要在ubuntu环境中加载ssh私钥。您需要将项目转移到您自己的用户存储库中 然后添加原点:
git remote add upstream your-ssh-here
git fetch upstream
git branch --set-upstream-to=upstream/master master
Github的文档非常具有解释性 我认为您必须按照指南中的最后步骤正确配置密钥
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
解决方案:
您必须在git hub配置文件中添加ssh密钥。请按照以下步骤解决此问题
希望这将对您有所帮助如果您在~/.ssh中拥有私钥并已将其添加到,但仍然无法提交通过ssh添加的Github repo,请确保将其添加到您的ssh代理:
ssh-add -k ~/.ssh/[PRIVATE_KEY]
您可以为多台服务器(例如Bitbucket和GitHub)添加多个私钥,它在处理git时将使用正确的私钥。如果您遇到403错误,以下是解决方案:
The requested URL returned error: 403
由于您正在使用另一个帐户注册您的帐户,因此您需要从windows中删除github凭据
control panel > user accounts > credential manager > Windows credentials > Generic credentials
then remove the Github keys
Hi@wyguf可能重复,如果有帮助,请接受我的回答。:)谢谢
\302\226git@github.com:权限被拒绝(公钥)。
Luan Si Ho的解决方案对我有效。我收到了欢迎信息,但git push-u origin master仍然无法正常工作
control panel > user accounts > credential manager > Windows credentials > Generic credentials
then remove the Github keys