错误:访问请求的URL时返回错误:403禁止访问

7

我有一个git 仓库。我在Windows上使用GUI客户端和Eclipse ADT中的EGit。通常我在Eclipse ADT中编辑并使用GUI客户端更新Github仓库。首先,我提交更改(创建缓冲区),然后同步,这样就可以将更改上传到实际仓库。

现在我在Linux(CentOS 6.4)上克隆了我的仓库。一切都设置好了。我改变了一些文件。然后我使用git addgit commit -m "message" -a命令,这个命令运行良好。但是我的实际GitHub仓库没有更新。经过一番搜索,我发现我们必须明确提供git push命令,然后才能更新到实际仓库。

[aniket@localhost Android]$ git push
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/aniket91/Android.git/info/refs

fatal: HTTP request failed

出了什么问题?没有防火墙或代理,并且我已经关闭了iptables服务。有人遇到过这种情况吗?应该怎么办?

按照这个答案后(它有点起作用),我得到了以下错误:

[aniket@localhost Android]$ git push origin master
The authenticity of host 'github.com (192.30.252.130)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

非常感谢您的建议。

3个回答

3

您提到的答案建议将URL从https更改为ssh。

只有在您拥有〜/ .ssh / id_rsa〜/ .ssh / id_rsa.pub且后者(公钥)已发布在您的GitHub ssh密钥中时,才能起作用。

请检查您的Egit ssh配置

http://wiki.eclipse.org/images/8/87/Egit-0.6-003-SshPreferences.png

如何生成SSH密钥并在GitHub设置中设置,请参考这里提供的逐步过程。


我想使用命令行来执行 git push origin master - Aniket Thakur
@AniketThakur 然后检查您的ssh配置:https://dev59.com/wGsz5IYBdhLWcg3wZm3Q#7927828 - VonC
感谢您的主要部分是生成SSH密钥并将其存储在您的Github设置中。 逐步操作--> https://help.github.com/articles/generating-ssh-keys - Aniket Thakur

1

我曾经遇到了相同的问题,原因是我在 Linux 系统下使用了 https git 访问。拉取没有问题,但推送时出现了错误。解决方案是切换为 ssh 访问,例如:

首先读取远程 URL:

$ git config --get remote.origin.url

https://github.com/yourname/project.git

如果你看到的是 https,那么将其改为 ssh,从你的 GitHub 项目 www 复制正确的 URL,并调用:
$ git remote set-url origin git@github.com:yourname/project.git

你可能仍然需要将(也许还要生成).ssh公钥放到Github上。为此,请查看VonC的答案。


0

所以我遇到了与git推送内容到存储库相同的问题。


错误信息:
错误:访问 https://github.com/bhanurhce/rhel6-exapmpleserver.git/info/refs 时,请求的URL返回错误:403 Forbidden
致命错误:HTTP请求失败

我的解决方案:

此错误主要是由于在git hub中来自本地机器的登录凭据。 您必须提供github的用户名和密码。

添加用户名:$ git config --global user.name "bhanurhce" 用户名应为github的用户帐户。

确认用户名:$ git config user.name

一旦您尝试推送,它将要求您输入密码:

$ git push -u origin master
密码(提供您的github密码。)

问题将得到解决。

即使您仍然遇到askpass错误

错误信息: [root@virtual-master git]# git push -u origin master

(gnome-ssh-askpass:47356):Gtk-WARNING **:无法打开显示:

然后通过命令解决:$ unset SSH_ASKPASS

所有内容都将正常工作。希望能有所帮助。

谢谢!!


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接