github 铺设403错误的处理

如果没有什么别的问题的话,推荐使用SSH的方式。请参考:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed

Pushing to Git returning Error Code 403 fatal: HTTP request failed


up vote241down votefavorite

119

I was able to clone a copy of this repo over HTTPS authenticated. I‘ve made some commits and want to push back out to the GitHub server. Using Cygwin on Windows 7 x64.

C:\cygwin\home\XPherior\Code\lunch_call>git push
Password:
error: The requested URL returned error: 403 while accessing https://MichaelDrog
[email protected]/derekerdmann/lunch_call.git/info/refs

fatal: HTTP request failed

Also set it up with verbose mode. I‘m still pretty baffled.

C:\cygwin\home\XPherior\Code\lunch_call>set GIT_CURL_VERBOSE=1

C:\cygwin\home\XPherior\Code\lunch_call>git push
Password:
* Couldn‘t find host github.com in the _netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * 0x23cb740 is at send pipe head!
* Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt
  CApath: none
* SSL connection using AES256-SHA
* Server certificate:
*        subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.
3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L
=San Francisco; O=GitHub, Inc.; CN=github.com
*        start date: 2011-05-27 00:00:00 GMT
*        expire date: 2013-07-29 12:00:00 GMT
*        subjectAltName: github.com matched
*        issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass
urance EV CA-1
*        SSL certificate verify ok.
> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/1.0.4
< Date: Thu, 15 Sep 2011 22:44:41 GMT
< Content-Type: text/plain
< Connection: keep-alive
< Content-Length: 55
< WWW-Authenticate: Basic realm="GitHub"
<
* Ignoring the response-body
* Expire cleared
* Connection #0 to host github.com left intact
* Issue another request to this URL: ‘https://[email protected]/dereker
dmann/lunch_call.git/info/refs?service=git-receive-pack‘
* Couldn‘t find host github.com in the _netrc file; using defaults
* Re-using existing connection! (#0) with host github.com
* Connected to github.com (207.97.227.239) port 443 (#0)
* 0x23cb740 is at send pipe head!
* Server auth using Basic with user ‘MichaelDrogalis‘
> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

< HTTP/1.1 401 Authorization Required
< Server: nginx/1.0.4
< Date: Thu, 15 Sep 2011 22:44:41 GMT
< Content-Type: text/plain
< Connection: keep-alive
< Content-Length: 55
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="GitHub"
* The requested URL returned error: 401
* Closing connection #0
* Couldn‘t find host github.com in the _netrc file; using defaults
* About to connect() to github.com port 443 (#0)
*   Trying 207.97.227.239... * 0x23cb740 is at send pipe head!
* Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt
  CApath: none
* SSL re-using session ID
* SSL connection using AES256-SHA
* old SSL session ID is stale, removing
* Server certificate:
*        subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.
3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L
=San Francisco; O=GitHub, Inc.; CN=github.com
*        start date: 2011-05-27 00:00:00 GMT
*        expire date: 2013-07-29 12:00:00 GMT
*        subjectAltName: github.com matched
*        issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass
urance EV CA-1
*        SSL certificate verify ok.
* Server auth using Basic with user ‘MichaelDrogalis‘
> GET /derekerdmann/lunch_call.git/info/refs HTTP/1.1
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache

* The requested URL returned error: 403
* Expire cleared
* Closing connection #0
error: The requested URL returned error: 403 while accessing https://MichaelDrog
[email protected]/derekerdmann/lunch_call.git/info/refs

fatal: HTTP request failed

These are the versions of git and curl that I have:

C:\Users\XPherior>git --version
git version 1.7.4.msysgit.0

C:\Users\XPherior>curl --version
curl 7.21.7 (amd64-pc-win32) libcurl/7.21.7 OpenSSL/0.9.8r zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp
smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate Largefile NTLM SSL SSPI libz

git github dvcs


share|edit

edited Apr 1 at 23:31

Cupcake
29.9k974100

asked Sep 15 ‘11 at 22:45

Mike
6,39062660

 

    

Look at the comment, which should be posted as an answer. Made it work with 1.7.1, had the missing User/Password prompt problem, too. Props to stackoverflow.com/a/9575906/805284 ... –  sjas Mar 1 ‘13 at 14:27
1  

check the user has read/write access to the repository –  Céline Aussourd May 1 ‘13 at 10:49
6  

In the future, don‘t paste "Authorization: Basic <stuff>" when showing example http headers. It‘s easy to base64 decode that and get your password. @mike: if you haven‘t changed your github password since you posted this question, I would suggest you do so. –  FlipMcF Jul 31 ‘13 at 22:07
1  

@FlipMcF Thanks man. Was unaware. Password changed. –  Mike Aug 1 ‘13 at 13:01
1  

@Mike NP. Now I get to shamelessly promote a little blog I wrote on it: goo.gl/bpae94 –  FlipMcF Aug 1 ‘13 at 17:03

show 1 more comment

27 Answers

activeoldestvotes


up vote379down voteaccepted

I just got the same problem and just figured out what‘s cause.

Github seems only supports ssh way to read&write the repo, although https way also displayed ‘Read&Write‘.

So you need to change your repo config on your PC to ssh way:

  1. edit .git/config file under your repo directory
  2. find url=entry under section [remote "origin"]
  3. change it from url=https://[email protected]/derekerdmann/lunch_call.git tourl=ssh://[email protected]/derekerdmann/lunch_call.git. that is, change all the texts before @ symbol to ssh://git
  4. Save config file and quit. now you could use git push origin master to sync your repo on GitHub

share|edit

edited Jan 8 ‘13 at 23:25

AtomicCharles
561312

answered Oct 14 ‘11 at 18:26

Sean
4,2481719

 

31  

This is often encountered when you clone with the git read-only address (which is the default when you aren‘t logged in) instead of the read+write ssh address. –  Nitrodist Nov 15 ‘11 at 15:22 
15  

My .git/config was more like url=https://github.com/mynickname/my_repo.git But I also changed it like url=ssh://[email protected]/mynickname/my_repo.git and it did the trick – Guillaume Flandre Dec 29 ‘11 at 21:16 
6  

You can change a repo url with git remote set-url command. See my answer below. –  ilzoff Jun 4 ‘12 at 22:33
4  

or simply change it from the command line using git remote set-url <name> [email protected]:<username>/<repo>.git –  Yasky Jul 9 ‘12 at 5:31
18  

For those looking for a non ssh solution, check a few of the other answers here. Adding your username to the https url seems to work. (change config url so that https://@github.com/... is [email protected]/...) – Cyrus Dec 12 ‘12 at 17:05

show 4 more comments


up vote160down vote

To definitely be able to login using https protocol, you should first set your authentication credential to the git Remote URI:

git remote set-url origin https://[email protected]/user/repo.git

Then you‘ll be asked for a password when trying to git push.

In fact, this is on the http authentication format. You could set a password too:

https://youruser:[email protected]/user/repo.git

You should be aware that if you do this, your github password will be stored in plaintext in your .git directory, which is obviously undesirable.


share|edit

edited Jan 28 at 0:32

answered Jul 6 ‘12 at 19:41

Thiago F Macedo
1,8201711

 

4  

SSH blocked at work so I have to use HTTPS. Adding the username fixes my issues. –  David Poole Oct 13 ‘12 at 15:40
3  

This should be the accepted answer. No reason to manually edit a config file when there‘s a command line interface to it. –  Steve Bennett Jun 12 ‘13 at 5:23
1  

Also, for me, this way ([email protected]) asked for password and worked, whereas ssh://[email protected] failed expecting public key auth. –  Steve Bennett Jun 12 ‘13 at 5:25
    

works and should be the accepted answer! Especially in environments in which ssh does not work, this is the way to go. Thanks! –  AndreasEK Oct 16 ‘13 at 14:14
1  

@Achint it‘s an authentication format. You could set your password toohttps://youruser:[email protected]/user/repo.git despite not secure –  Thiago F MacedoDec 2 ‘13 at 17:24 

show 1 more comment


up vote63down vote

One small addition to Seans answer.

Instead of editing .git/config file manually, you can use git remote set-url command.

In your case it should be:

git remote set-url origin ssh://[email protected]/derekerdmann/lunch_call.git

I find it easier and cleaner, than messing around with dot-files.


share|edit

answered Jun 4 ‘12 at 22:29

ilzoff
877811

 

    

I don‘t know if this is just an old post and git has changed, but as today to fix the problem I had to use git remote set-url origin ssh://[email protected]:derekerdmann/lunch_call.git with a colon between the github.com and the repo name –  KevinL Aug 20 at 19:49

add a comment


up vote27down vote

The other answers that suggest switching to SSH sort of miss the point. HTTPS is supported, but you must log in with you GITHUB password, not your SSH passphrase (which was what was giving me the same exact error).

I was having the same problem, but making sure to use my actual GitHub password at the terminal password prompt fixed the solution with no alteration to the config, or resorting to SSH.

The reason it is important to note this, is many public institutions (such as my school) will block SSH, but allow HTTPS (which is the only reason I started cloning over HTTPS in the first place).

Hope that helps anyone else having the same issue...


share|edit

answered Jan 17 ‘12 at 17:27

BMB
99176

 

    

but why? I didn‘t have to do that in the past. Did a certificate expire, or something? –  Thufir Jun 11 ‘12 at 11:42
    

Not sure, I‘m not an expert, that‘s just how I got it to work in my case :) –  BMB Dec 4 ‘12 at 9:45

add a comment


up vote16down vote

Edit .git/config file under your repo directory

Find url= entry under section [remote "origin"]

Change it from url=https://github.com/rootux/ms-Dropdown.git tohttps://[email protected]/rootux/ms-Dropdown.git

where USERNAME is your github user name


share|edit

edited Feb 21 at 22:05

Zach Saucier
11.8k41346

answered Nov 7 ‘12 at 9:39

Gal Bracha
1,6621231

 
add a comment

up vote12down vote

I think @deepwaters got the answer correct for older versions. The HTTPS URL needs to have the username. I had git 1.7.0.4 and git push origin master wouldn‘t even ask for a password till I added it.


share|edit

answered Jun 27 ‘12 at 14:44

nisah
577616

 

    

Yes, this is correct! –  Rafael Reiter Mar 25 ‘13 at 15:58

add a comment


up vote7down vote

Upgrade your git. GitHub has answered this question at https://help.github.com/articles/error-the-requested-url-returned-error-403.


share|edit

answered Jun 20 ‘12 at 19:03

gsf
18124

 

    

It‘s half the answer, for sure. Other half is what we have here. –  Mike Jun 20 ‘12 at 19:06

add a comment


up vote6down vote

Figured it out. I cloned over HTTPS. Setting up my public SSH keys, cloning over SSH, and pushing over SSH fixed it.


share|edit

answered Sep 16 ‘11 at 3:29

Mike
6,39062660

 

    

Hmmm... but what when you can‘t use anything but https, because of a corp firewall, for instance?... According to the github blog, the https access was added to github just for that purpose? –  filofel Nov 21 ‘11 at 14:59
    

I really don‘t know. I always clone over SSH now. –  Mike Nov 22 ‘11 at 1:45
    

Just for posterity (I noticed the timestamp), in regards to filofel‘s comment: Check out my answer listed above. I have the same restriction you mention, at my school, and found I was supplying the wrong password/passphrase to the terminal prompt. Hope it helps any others with the same issue. –  BMB Feb 25 ‘12 at 0:10 

add a comment


up vote4down vote

Just add you username into url like this : https://[email protected]/islam9/bootstrap-rtl

please check: http://islamkhalil.wordpress.com/2012/12/06/github-error-pushing-to-git-returning-error-code-403-fatal/


share|edit

answered Dec 6 ‘12 at 18:37

islam
3412619

 

    

That worked for me too –  svassr Mar 19 ‘13 at 22:23

add a comment


up vote4down vote

A 403 code is "Forbidden". The server saw your request and refused it. Do you have permission to push to that repository?


share|edit

answered Sep 16 ‘11 at 0:32

Nick Veys
10.3k1440

 

    

Me and a friend are having the same problem. The repo is mine, and he can‘t push. How do we fix this? – gibson Nov 11 at 17:07

add a comment


up vote2down vote

For anyone curious, my mac machine vs lucid vm ran git 1.7.6 vs 1.7.0.4, and the exact same repo was pushable from my mac (newer git) but not the VM

Same curl version. Perhaps some older git versions don‘t support https pushes?


share|edit

answered Mar 5 ‘12 at 23:49

patcon
1,015166

 

    

Yes, https push to github works here (even through proxy with password). I use git 1.7.3. For me, it failed first because I typed the wrong password. –  guettli Apr 26 ‘12 at 10:37
5  

It works for me with git 1.7.1, but there is one thing you have to pay attention too (and that was what I missed in my first try): Give the user name in the HTTPS-URL, i.e.url=https://[email protected]/username/repo.git –  lwho Jun 16 ‘12 at 10:04

add a comment


up vote2down vote

change it from

url=https://[email protected]/derekerdmann/lunch_call.git

to

url=ssh://[email protected]/derekerdmann/lunch_call.git

It works!

Do not forget the "git" before the "@".


share|edit

edited Oct 18 ‘12 at 1:16

Juan Sosa
2,85111430

answered Oct 18 ‘12 at 1:07

JimmyDong
585

 
add a comment

up vote2down vote

Sometimes there is nothing wrong with settings, and there are some problems on github servers.

https://status.github.com - current status of github :)


share|edit

answered Apr 1 at 23:23

noisy
70821750

 

    

You can also get GitHub status updates from their Twitter status account. –  Cupcake Jul 29 at 16:06

add a comment


up vote1down vote

I had this problem right now, and it turned out that my server /etc/resolver.conf file had a bad ip address. Might help others.


share|edit

answered Aug 29 ‘12 at 11:57

RichardW11
520212

 
add a comment

up vote1down vote

It could be an accounting issue. The Github account of the upstream (private) repo owner may not be financial. I‘ve seen this where the client‘s credit card expired.


share|edit

answered May 7 ‘13 at 0:01

gnoll110
916

 
add a comment

up vote1down vote

I figured out my own variation of this problem.

The issue was not changing the protocol from https to ssl, but instead, setting the Github global username and email! (I was trying to push to a private repository.

git config --global user.email "[email protected]"

git config --global user.name "Your full name"

share|edit

answered Feb 17 at 21:08

Lucas Ou
8401033

 

    

Does not work for me. Config has been set, use github.com.. with no ‘@‘ in it –  ses Mar 13 at 2:19

add a comment


up vote1down vote

After changing https to http within gitbox app, it worked for me.


share|edit

answered Mar 10 at 19:13

Alex Stone
8,9821585182

 

    

got 403 while accessing by http. –  ses Mar 13 at 2:13

时间: 2024-07-29 06:51:36

github 铺设403错误的处理的相关文章

一次apache出现403错误排查

客户的zhcp面板坏了,手动给他创建了apache配置 但是配置完成后一直访问不了,提示403错误. 手动编辑了phpinfo文件,但是仍然提示403 2.vim -O xxx.conf  common.conf 对比正常配置文件,发现没有什么问题 3.怀疑配置文件没有读取成功,手动在httpd.conf添加额外的Include /path/to/file ,重启apache 发现问题依旧 4.查看日志,发现有日志生成,说明配置文件有被读取,怀疑是仍然是配置问题 5.删除日志,重启apache,

phpStudy配置多站点多域名步骤,及遇到的403错误解决方式

首先,打开站点域名管理,配置如下,网站域名和目录都可以自己设置,端口重设一个,不要是80了,然后先新增再保存. 打开配置文件vhosts,会看到新增了801端口的东西 在配置文件http.conf中添加 ,在80后添加新端口号 然后在hosts文件中配置下,127.0.0.1       www.aaa.com 再就是,玛德GG了,出现forbidden了,403,没有访问权限. 废了很大劲终于找到了解决方案,下面先复制解决方案的内容,最后附上原文的地址. 第一步 在C:\Windows\Sys

ASP.NET MVC4中的bundles特性引发服务器拒绝访问(403错误)

当你使用bundles.Add方法添加StyleBundle和ScriptBundle对象的时候一定要注意,StyleBundle和ScriptBundle的构造函数的参数virtualPath指定的虚拟路径一定不能是当前ASP.NET项目中真实存在的一个文件夹路径,否则当你把你的站点部署到IIS上后,会发现MVC页面上用@Styles.Render和@Scripts.Render生成的url路径会被IIS拒绝,IIS提示 禁止访问 403错误. 下面是有个老外遇到了相同的问题,在StackOv

wampserver下打开phpMyAdmin出现403错误的问题解决方法

图1 图2 wamp下打开phpMyAdmin出现403错误的问题解决方法安装完wamp后打开其下的phpMyAdmin也就是路径http://localhost/phpmyadmin/ 出现[图一] 解决方法直接贴图如下:[图二]apache --> Alias目录 --> http://localhost/phpmyadmin/ --> Edit alias代码如下: <Directory "c:/wamp/apps/phpmyadmin3.5.1/">

win8安装wampserver报403错误解决方法

看着别人开始体验win8了,前几天我也安装了win8系统,总体来说还不错,但是今天安装完Wampserver后,浏览器输入localhost,竟然报了403错误,我以为我安装出错了,后来研究了半天,发现输入127.0.0.1可以访问.习惯localhost访问的我顿感蛋疼不已.无奈只能打开度娘,各种搜索相关资料,终于找到了解决方案. php错误: Forbidden You don't have permission to access / on this server. 解决方法: 打开htt

apache服务器 403错误 禁止访问解决办法

打开网页,结果访问提示:403错误!关闭了IE的"显示友好的HTTP错误",显示没有权限访问(You don't have permission to access / on this server)! Apache,版本2.2.8,安装完成后,进行相关测试: 配置了下php的php.in文件,再次localhost打开发现错误: HTTP 错误 403 - 禁止访问,即403 Forbidden:You don't have permission to access / on thi

nginx配置403错误页面

建立403 error 页面, 403.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head><title>Error 403</title></head><body&g

记一次httpd报403错误的解决

由于移动云最近有免费试用活动,所以领了一台玩玩. 领过来之后开始运行我自己的lamp脚本,运行完之后由于禁8080端口,于是开始修改端口 修改了httpd.conf和虚拟主机配置,配置完后重启. 这个时候报了一个错误:好像是什么socket什么的,没管它,后来查询了一下,是没有在/etc/hosts中定义主机名,果断定义. 在/etc/hosts中加入一行 127.0.0.1主机名 接着重启,错误消失. 这个时候我开始访问网页,发现网页报403错误,一开始我还以为是配置错误,于是开始查配置:配置

Django1.8:403错误:CSRF verification failed. Request aborted.

问题:Django 403错误:CSRF verification failed. Request aborted. 原因:需要加cookie验证 解决方法: 1.在view.py中增加 from django.template import Template, Context, RequestContext def newproject(request): …… return render_to_response('newproject.html', locals(),context_inst