53

Trying to clone a private repository I have access to using HTTPS protocol, as that is only allowed outgoing traffic.

git does not ask for passwords, just failed.

error: The requested URL returned error: 403 Forbidden while accessing https://github.com/blah/blahblah.git/info/refs

What am I missing ?

Chris Maes
  • 35,025
  • 12
  • 111
  • 136
Ask and Learn
  • 8,661
  • 8
  • 37
  • 43

6 Answers6

92

Did you try inserting the username (and optionally password) in the clone URL?

 git clone https://username@github.com/blah/blahblah.git

or if you accept the consequences of storing your password in plain view:

 git clone https://username:password@github.com/blah/blahblah.git

See this thread with a lot of good info:

How to provide username and password when run "git clone git@remote.git"?

EDIT: My original answer was just a quick fix, without understanding the full history of the asker, and it also works unattended, but for best security practices its better to let Git store your password. See @phpguru's answer: https://stackoverflow.com/a/29018371/257090 as well.

codenheim
  • 20,467
  • 1
  • 59
  • 80
40

The answer by @mrjoltcola should work, but if you would prefer not to place your github password in your server's bash_history in plaintext on the command line then you can omit the password and be prompted for it:

git clone https://username@github.com/organizationname/reponame.git
Password:

I like that better.

phpguru
  • 2,351
  • 2
  • 23
  • 33
6

If you are using two-factor authentication, you go to this link first:

https://github.com/settings/tokens

Create a token, and then use it as the password:

git clone https://username:token@github.com/blah/blahblah.git
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Eduardo Kazan
  • 61
  • 1
  • 2
2

While I was using HTTPS connections to AWS CodeCommit repositories on Linux, macOS, or Unix I got the same error.

I needed to enable the Git credential UseHttpPath by using below command. git config --global credential.UseHttpPath true

0

Github no longer permit password authentication over https: you need to use a personal access token instead.

git clone https://<your_token>@github.com/<username>/<repo_name>.git
snakecharmerb
  • 47,570
  • 11
  • 100
  • 153
0

If you try logging in with a new account, you may still encounter authentication failures after creating a new token. You need device activation to remember your credentials. There are two ways, but I highly recommend GitHub CLI.

Just follow the steps in GitHub Docs below.

https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git

After entering the code displayed on your device to activate the device, I can use the git clone immediately.