Authentication Failed
So, the other 24-hour interval I idea of using my long-forgotten GitLab account for storing and tracking all the customization I make to the Linux Handbook website.
I created a new repository on the GitLab web interface and I went on to push the directory I had on my personal system.
Everything was fine until I tried to push the code to remote repository on GitHub. It gave me a fatal error saying "Authentical failed for xyz repository".
Here's what the mistake looked like:
[email protected]:~/Documents/Local-Code$ git push button -u origin master Username for 'https://gitlab.com': gitlab_profile_username [email protected]': remote: HTTP Basic: Access denied fatal: Authentication failed for 'https://gitlab.com/gitlab_account_username/gitlab_repository/' If you are facing a similar issue, let me prove you lot how to prepare this error.
Handling "remote: HTTP Basic: Access denied" Fault With GitLab
The main line that gives some inkling nigh the root cause of this error is this one:
remote: HTTP Bones: Access denied Why do I say that? Because your GitLab repository is using HTTPS. It expects to have a secure connection between your system and your repository.
Now, should it not be automatically using HTTPS? No! Not anymore.
GitLab has changed its policy and information technology now expects you lot to utilize your own SSH key to authenticate with your GitLab repository.
In other words, to push a code from your local system to your remote GitLab repository, you lot must create an SSH key-pair and add the public central to your GitLab contour.
I am using Linux and then the steps are best followed on Linux. If you are using Windows or macOS, you should take a hint and check how to do the same on your operating system.
Commencement bank check if you lot already have SSH keys:
ls ~/.ssh/id_rsa.pub If you don't have it, create it using the next department else spring to the section afterwards this one.
Creating SSH keys (if you lot don't have it already)
I am using Ubuntu so the steps are for Ubuntu. If you are using some other distributions, the steps may or may not be unlike.
Open a terminal and use the following command:
ssh-keygen You should see an output similar this:
Generating public/private rsa key pair. Enter file in which to save the key (/user_home/.ssh/id_rsa): Press the enter key and become with the default choice. You lot may exist asked to enter a password to secure your SSH key. If yous set a password, you'll have to enter it every time you lot endeavor to make a SSH connection using the generated SSH primal. Y'all may or may not gear up a countersign for the SSH central.
10 Actionable SSH Hardening Tips to Secure Your Linux Server
Worried about the security of your Linux server? Acquire some easy to implement tips on securing SSH and make your Linux server more than secure.
Adding public SSH key to GitLab
If you take created SSH key on your personal computer, yous should find it in the .ssh directory under your home directory in well-nigh Linux distributions. Display its content with this control:
true cat ~/.ssh/id_rsa.pub Copy the content of your public key. Now log in to your GitLab account, go to User Settings and expect for SSH keys in the left sidebar. Alternatively, you tin can simply go to this page when logged in.
You'll run across a field for adding the public key. Just paste the key hither. Requite it a title to easily recognize which figurer this key belongs to. Unless you did something on your ain, SSH keys don't take an expiry date by default. So leave the expiry field untouched.
Washed with everything? Hit the Add together cardinal push.
You can add more than 1 SSH keys. That's normal if you have more than than one computer.
Check if you can push the code to GitLab now
And so, you added your SSH key to your GitLab profile. Things should be adept at present. Time to verify it.
Try to push your lawmaking once again. Come across if information technology works. Normally, you should see an output like this if it is successful:
[email protected]:~/Documents/Local-Code$ git push -u origin chief Username for 'https://gitlab.com': gitlab_account_username Password for 'https://[electronic mail protected]': Enumerating objects: 127, done. Counting objects: 100% (127/127), done. Delta pinch using up to iv threads Compressing objects: 100% (122/122), done. Writing objects: 100% (127/127), 401.thirty KiB | half dozen.37 MiB/s, done. Full 127 (delta 14), reused 0 (delta 0) remote: Resolving deltas: 100% (fourteen/fourteen), done. To https://gitlab.com/gitlab_account_username/gitlab_repository.git * [new co-operative] principal -> chief Branch 'master' fix to rails remote branch 'master' from 'origin'. Still see fault? Mind the divergence between GitLab profile username and the account username!
I learned it the hard way.
GitLab has two usernames: profile username and account username.
You tin can hands change the profile username without any consequences. But changing the account username can be catastrophic.
The account username is what you lot'll meet in the URL of your GitLab repository:
https://gitlab.com/gitlab_account_username/repository_name While creating a new GitLab repository from its website, GitLab suggested using the profile username in the Git config settings on the personal computer.
I did that and I tried to utilise the same profile username while pushing the code to the repository. Unsurprisingly, information technology got denied even after calculation the SSH central:
[e-mail protected]:~/Documents/Local-Code$ git push -u origin master Username for 'https://gitlab.com': gitlab_profile_username Password for 'https://[email protected]': remote: HTTP Basic: Access denied fatal: Authentication failed for 'https://gitlab.com/gitlab_account_username/gitlab_repository.git/' So, the play tricks is to apply the GitLab account username here. When I did that, the push to the remote GitLab repository was successful.
Did it work for you?
Well, I shared my ordeal with pushing code to GitLab repository. I hope this helped yous with the "fatal: Authentication failed" error as well.
Did it work for y'all? Do let me know with a yes or no in the comment section.
Source: https://linuxhandbook.com/gitlab-authentication-failed/
0 Response to "Authentication Failed"
Post a Comment