GitLab remote: HTTP Basic: Access denied and fatal Authentication

GitGitlab

Git Problem Overview


Unlike this post, I am on macOS.

I have the password configured in GitLab. I also have an SSL key created after the project was made on GitLab.

When I use an existing folder for a new project and follow the steps below, I am prompted to enter my GitLab username and password.

Existing folder

cd existing_folder
git init
git remote add origin https://gitlab.com/sobopla/Geronimod.git
git add .
git commit -m "Initial commit"
git push -u origin master

After the password is entered I get the following error.

>remote: HTTP Basic: Access denied >fatal: Authentication failed for 'https://gitlab.com/myname/myproject';

Git Solutions


Solution 1 - Git

It happens every time I'm forced to change the Windows password and none of the above answers helped me.

Try the below solution which works for me:

  1. Go to Windows Credential Manager. This is done in an EN-US Windows by pressing the Windows Key and typing 'credential'. In other localized Windows variants you need to use the localized term (See comments for some examples).

    alternatively you can use the shortcut control /name Microsoft.CredentialManager in the run dialog (WIN+R)

  2. Edit the git entry under Windows Credentials, replacing old password with the new one.

Solution 2 - Git

For me, the following worked:

Do not use your GitLab password, but create an access token and use it instead of your password:

  1. In GitLab, at the top-right corner, go to Personal Profile → Settings → Access Tokens Step 1

  2. Create a new personal access token (check the api option) Step 2

  3. git clone ...

  4. When you are asked for your password, copy and paste the access token instead of your GitLab password

    Step 3

Solution 3 - Git

You can try the following command:

git config --system --unset credential.helper

Then, enter a new password for Git remote server.

Solution 4 - Git

I got the same error and I solved this by :

  1. Apply command from cmd (run as administrator)

git config --system --unset credential.helper

  1. And then I removed gitconfig file from C:\Program Files\Git\mingw64/etc/ location (Note: this path will be different in MAC like "/Users/username")
  2. After that use git command like git pull or git push, it asked me for username and password. applying valid username and password and git command working.

hope this will help you...

Solution 5 - Git

The only thing that worked for me was using https://username:[email protected]/user/projectgit instead of https://gitlab.com/user/projectgit. See https://gitlab.com/gitlab-com/support-forum/issues/1654

Solution 6 - Git

Go to Windows Credential Manager (press Windows Key and type 'credential') to edit the git entry under Windows Credentials. Replace old password with the new one.

Windows Credential Manager

Solution 7 - Git

Just add your username before the domain:

https://**username**@gitlab.com/user/projectgit

And the assistant will ask you the password

Solution 8 - Git

I was also facing the same issue. The reason for the problem was authentication error. To solve this problem go to Control Panel -> Credential Manager -> Generic Credentials here find your gitlab credential and edit them. Make sure your ID password is right or not

enter image description here

Solution 9 - Git

If you are using git > 2.11 and using Kerberos to interact with Gitlab you need set this configuration in your local git to avoid the remote: HTTP Basic: Access denied error.

Source

Solution 10 - Git

Well, I faced the same issue whenever I change my login password.

Below is the command I need to run to fix this issue:-

git config --global credential.helper wincred

After running above command it asks me again my updated username and password.

Solution 11 - Git

Note: do not mix GitLab SSL settings and GitLab SSH keys.

If what you have configured in your GitLab profile is an SSH public key, then your HTTPS URL would not use it.

Regarding your HTTPS credentials, double-check:

  • if the two-factor authentication is disabled, or

  • if you have special characters in your username or password, or

  • if you have a Git credential helper: git config credential.helper.

Solution 12 - Git

Before digging into the solution lets first see why this happens.

Before any transaction with git that your machine does git checks for your authentication which can be done using

  1. An SSH key token present in your machine and shared with git-repo(most preferred) OR
  2. Using your username/password (mostly used)

Why did this happen

In simple words, this happened because the credentials stored in your machine are not authentic i.e.there are chances that your password stored in the machine has changed from whats there in git therefore

Solution

Head towards, control panel and search for Credential Manager look for your use git url and change the creds.

There you go this works with mostly every that windows keep track off

Solution 13 - Git

It happens if you change your login or password of git service account (GitHub or GitLab, Bitbacket, etc). You need to change it in Windows Credentials Manager too.

So, type "Credential Manager" (rus. "Диспетчер Учетных Данных") in Windows Search menu and go to your git service account and change data too.

enter image description here

Solution 14 - Git

I beleive I'm little late here. But I think this would help the new peeps!

My Errors were: remote: HTTP Basic: Access denied

remote: You must use a personal access token with 'read_repository' or 'write_repository' scope for Git over HTTP.

remote: You can generate one at https://gitlab.com/profile/personal_access_tokens

fatal: Authentication failed for 'https://gitlab.com/PROFILE_NAME/REPO_NAME.git/';

I'm on Ubuntu but this worked for me:

  1. Goto https://gitlab.com/profile/personal_access_tokens
  2. Create new token and mark check to all.
  3. Copy your token
  4. Now go to your Terminal and paste it like this.

git clone https://oauth2:[email protected]/PROFILE_NAME/REPO_NAME.git/

Solution 15 - Git

Open command prompt as administrator then run this command:

git config --system --unset credential.helper

Solution 16 - Git

Try this:

  1. Go to: C:/Users/(YourUserName)/
  2. Delete file .gitconfig

Solution 17 - Git

There are two ways I got around this problem:

  1. I added my username to the front of the remote URL (https://username@gitRepoURL)
  • Not always the best solution; where I work, even though we're slowly moving towards using GIT, we have our applications on a network drive, so if I do this, only I can push changes even if someone else worked on a feature.
  1. I can't run git config --system --unset credential.helper from GIT Bash, so I had to open up an Admin Command Prompt and run it there (this assumes you installed GIT such that it can run from both GIT Bash and the Command Prompt). From Bash, I get a "could not lock config file" error.

Solution 18 - Git

It is certainly a bug, ssh works with one of my machines but not the other. I solved it, follow these.

  1. Generate an access token with never expire date, and select all the options available.
  2. Remove the existing SSH keys.
  3. Clone the repo with the https instead of ssh.
  4. Use the username but use the generated access token instead of password.

enter image description here

alternatively you can set remote to http by using this command in the existing repo, and use this command git remote set-url origin https://gitlab.com/[username]/[repo-name].git

Solution 19 - Git

Same problem with Sourcetree On Mac

Solution: Delete the password in keychain access.

enter image description here

https://community.atlassian.com/t5/Sourcetree-questions/SourceTree-quot-fatal-Authentication-failed-for-quot/qaq-p/201844

When you try to push again it will ask for your password.

Solution 20 - Git

Go to Control Panel->Credential Manager->Windows Credentials select github or gitlab credentials and modify it. This is for windows10

Solution 21 - Git

i removed gitlab credential from 'Credential Manager' in windows and pushed successfully

Solution 22 - Git

When I had the same problem,

I solved it by removing the file "passwd" in

C:\Users\<USERNAME>\AppData\Local\Atlassian\SourceTree

After removing Sourcetree will prompt for the password.

Note:
OS Version : win10 
Sourcetree Version:  3.1

Solution 23 - Git

For me it was some other git URL placed in config file, so I did change it manually:

  1. Move to .git/config file and edit it,
  2. Remove invalid URL(if it's there) and paste the valid git SSH/HTTP URL like below way:
[remote "origin"]
        url = git@gitlab.com:prat3ik/my-project.git

And it was working!!

Solution 24 - Git

Strangely enough, what worked for me was to sign out and sign back in to the GitLab web UI.

I have no earthly idea why this worked.

Solution 25 - Git

it worked for me: I use Mac and I wrote the path on finder:

~/Library/Application Support/SourceTree

I deleted the auth file which should be like

[email protected]

then tried to push and pull the code from the source tree and it worked.

You can also read the following answers:

https://community.atlassian.com/t5/Sourcetree-questions/How-to-update-HTTP-S-credentials-in-sourcetree/qaq-p/297564

Solution 26 - Git

For Mac user:

  1. Go to keychain and delete gitlab accounts
  2. Go to your project path in terminal and simply type git pull
  3. Then you will be asked for username and password for gitlab
  4. Enter your username which you will find out in gitlab account in profile section.
  5. Then after that enter you updated password here.
  6. Here we go, again try to push your code, it may help you guys.

Solution 27 - Git

I had the same problem using GitLab, and here's how i fixed it:

  1. Generate an access token: to do so go to settings/access tokens, then give it a name and expiration date and submit.

  2. In your project files open the "config" file in ".git" directory: /.git/config.

  3. You will find a line like this:

    [remote "origin"] url = https://[username]:[token]@your-domain.com/your-project.git

  4. You will have your gitlab username instead of [username], and you should replace [token] with your token generated in step 1.

  5. Save the changes.

Solution 28 - Git

In my case I reinstalled to the latest version of git (currently 2.16.2). I don't know if it was that my old version of git was outdated, but I read on a github page that this should be done if you stumble into https cloning errors. I figured it was an https cloning error as the error focuses on HTTP Basic, while GitLab uses HTTPS. I might be wrong in this thought process, but the solution helped in my case, and I hope this helps anyone in the future!

Solution 29 - Git

None of the above solutions worked for me and I don't have admin rights on my laptop, but they eventually led me to the git tools credential storage doc :

My setup Windows 10 | git version 2.18.0.windows.1 | Clone through HTTPS link

This solution works if you use wincred as credential helper :

> git config --global credential.helper
wincred

Changing the helper to "cache" should do the trick, as it will ask you to provide your credentials again. To set it to cache, just type :

> git config --global credential.helper cache

Check your update is active:

> git config --global credential.helper
cache

You should now be able to clone / pull / fetch as before.

Solution 30 - Git

GO TO C:\Users\<<USER>> AND DELETE THE .gitconfig file then try a command that connects to upstream like git clone, git pull or git push . You will be prompted to re-enter your credentials. Kindly do so.

Solution 31 - Git

So for me the problem was that I had created my GitLab account via linking my GitHub account to it. This meant that no password formally existed for the account as it was created via hotlink between GitHub and GitLab. I fixed it by going to GitLab Settings -> Password -> and writing the same password as my GitHub account had.

Solution 32 - Git

If your trying to login Gitlab with your existing Git account. You need to reset your password of Gitlab, for the first time.

  1. Step: Navigate to setting by clicking your profile icon( drop down menu on top right corner).
  2. Step: Go to settings
  3. Step: Click on the lock icon or glyphicon icon(i.e password).
  4. Step : Enter the new password for Gitlab.

Solution 33 - Git

When the Windows Credential Manager asks for your credentials to access GitLab, those are username and password you use when accessing GitLab. EG: use your email and password.

Solution 34 - Git

Just for reference, I encountered this issues while using the URL wrongly after I generated and pasted the ssh_rsa.pub to the SSH Keys in gitlab.

$ git clone http://gitlab.x
Cloning into 'start-up'...
remote: HTTP Basic: Access denied
remote: You must use a personal access token with 'api' scope for Git over HTTP.
remote: You can generate one at http://gitlab.x

Solved by using the following URL instead.

$ git clone [email protected]/your_project.git

Solution 35 - Git

On mac use KeyChain -> Login -> Password: change password

Solution 36 - Git

I had to do below two steps to resolve this issue

  1. create ssh-keygen and add the public key to my gitlab account

  2. disable https using below command

    > git config --global http.sslVerify false

enter image description here

Solution 37 - Git

There is another reason for this error apart from invalid credentials in your credential manager.

I had a problem where my account was using LDAP for authentication but still had a password expiration date set. Because the server was configured to use LDAP authentication only, the password expiration was not visible in the web UI and became only an issue after GitLab published a security fix with version 13.12.2.

You can check and edit the password_expires_at attribute of a user account via the GitLab Rails Console. Setting it to nil solved the issue and got the LDAP authentication working again.

Solution 38 - Git

go to credential setting on your windows computer and Remove https://gitlab.com/sobopla/Geronimod.git

Solution 39 - Git

I've faced this same issue after once I've entered the wrong credentials of my git account. The thing that did work for me is, open keychain Access -> Password -> find your entered wrong password and update it and hit save, after that you will be able to perform your operations on git without any issue.

I hope this works for you.

Solution 40 - Git

I had the same issue but before I went ahead to implement any of the suggestions on here, I checked if I was still logged into my github account. I had the problem while working in my Gitlab account. I found out I was still logged into my Github account and I logged out of the account immediately. I tried to clone again in Gitlab and I didn't have the error and the clone was successfully.

Solution 41 - Git

You have to update the config file inside the .git directory with current access token. See This Link where I resolved the problem caused by accidentally changing the access token. I was using GITLAB and CLion,

Solution 42 - Git

I got the same error and I solved this by :

  1. Open Windows search
  2. Type: Git Bash
  3. Click second mouse button and select: Run as administrator
  4. Go to your project directory: cd "C:\path\to\our\project\name"
  5. Execute command: git config --system --unset credential.helper NB : On linux run this command with sudo command: sudo git config --system --unset credential.helper

Solution 43 - Git

I tried with browser URL for the repository then

git clone $(browserURL)

it prompted for my username and then my password

It worked fine then

Solution 44 - Git

I have same problem i followed these steps and it has been resolved. step 1:- set username amd password setp 2:- git push -f origin

Solution 45 - Git

Create a new access token from gitlab ->setting --> access token

Solution 46 - Git

For me, i created a personal access token and then updated my git origin as thus:

https://<personal_access_token_name>:<personal_access_token>@gitlab.com/username/your-project.git

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionjeancodeView Question on Stackoverflow
Solution 1 - GitmproView Answer on Stackoverflow
Solution 2 - GitJavAlexView Answer on Stackoverflow
Solution 3 - GithatanoohView Answer on Stackoverflow
Solution 4 - GitBharti LadumorView Answer on Stackoverflow
Solution 5 - GitPaulo MorgadoView Answer on Stackoverflow
Solution 6 - GitAndy QuirozView Answer on Stackoverflow
Solution 7 - Gitgal007View Answer on Stackoverflow
Solution 8 - GitKshama JainView Answer on Stackoverflow
Solution 9 - GitPigueirasView Answer on Stackoverflow
Solution 10 - GitVikash PandeyView Answer on Stackoverflow
Solution 11 - GitVonCView Answer on Stackoverflow
Solution 12 - GitManasvi MittalView Answer on Stackoverflow
Solution 13 - GitDyno CrisView Answer on Stackoverflow
Solution 14 - GitGauravView Answer on Stackoverflow
Solution 15 - GitMD. Shafayatul HaqueView Answer on Stackoverflow
Solution 16 - Gitboy_vkallstarView Answer on Stackoverflow
Solution 17 - GitArtorias2718View Answer on Stackoverflow
Solution 18 - GitSitecore SamView Answer on Stackoverflow
Solution 19 - GitrotoavaView Answer on Stackoverflow
Solution 20 - GitSanjXView Answer on Stackoverflow
Solution 21 - GitsaiedkiaView Answer on Stackoverflow
Solution 22 - GitJean-Philippe VankemmelView Answer on Stackoverflow
Solution 23 - GitPratik PatelView Answer on Stackoverflow
Solution 24 - GitATOMPView Answer on Stackoverflow
Solution 25 - GitBurcu KutluayView Answer on Stackoverflow
Solution 26 - Gitvikash kumarView Answer on Stackoverflow
Solution 27 - GitBadrView Answer on Stackoverflow
Solution 28 - GitAndreas ForslöwView Answer on Stackoverflow
Solution 29 - GitlkostkaView Answer on Stackoverflow
Solution 30 - GitDennis MutegiView Answer on Stackoverflow
Solution 31 - GitMomchillView Answer on Stackoverflow
Solution 32 - GitGaniView Answer on Stackoverflow
Solution 33 - GitaercolinoView Answer on Stackoverflow
Solution 34 - GitHearenView Answer on Stackoverflow
Solution 35 - GitYu JiaaoView Answer on Stackoverflow
Solution 36 - GitMateenView Answer on Stackoverflow
Solution 37 - GitAndyView Answer on Stackoverflow
Solution 38 - GitTaib LamkhazniView Answer on Stackoverflow
Solution 39 - GitHeena BeriyaView Answer on Stackoverflow
Solution 40 - GitOthelloView Answer on Stackoverflow
Solution 41 - GitJanith PriyankaraView Answer on Stackoverflow
Solution 42 - GitWafa BergaouiView Answer on Stackoverflow
Solution 43 - GitSaurabh VermaView Answer on Stackoverflow
Solution 44 - Gitsachin kannaujiyaView Answer on Stackoverflow
Solution 45 - GitAbhijit somView Answer on Stackoverflow
Solution 46 - GitMacdonaldView Answer on Stackoverflow