Repository Access Denied. Access via a Deployment Key Is Read-only. Bitbucket

So, the other day I thought 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 button the code to remote repository on GitHub. It gave me a fatal error saying "Authentical failed for xyz repository".

Hither'due south what the error looked like:

            [email protected]:~/Documents/Local-Code$ git push -u origin principal Username for 'https://gitlab.com': gitlab_profile_username [email protected]':  remote: HTTP Bones: Access denied fatal: Authentication failed for 'https://gitlab.com/gitlab_account_username/gitlab_repository/'          

If you are facing a similar upshot, permit me bear witness you how to fix this mistake.

Handling "remote: HTTP Bones: Admission denied" Mistake With GitLab

The principal line that gives some clue about the root cause of this error is this one:

            remote: HTTP Basic: Access denied          

Why do I say that? Because your GitLab repository is using HTTPS. It expects to have a secure connectedness between your organization and your repository.

At present, should it not be automatically using HTTPS? No! Not anymore.

GitLab has changed its policy and it now expects you to utilize your own SSH key to authenticate with your GitLab repository.

SSH key in GitLab prompt

In other words, to push button a code from your local organization to your remote GitLab repository, you must create an SSH central-pair and add the public cardinal to your GitLab contour.

I am using Linux so the steps are best followed on Linux. If you are using Windows or macOS, you should accept a hint and cheque how to practice the same on your operating system.

First cheque if you lot already have SSH keys:

            ls ~/.ssh/id_rsa.pub          

If you don't have it, create it using the next section else jump to the section after this one.

Creating SSH keys (if you don't have it already)

I am using Ubuntu and then the steps are for Ubuntu. If yous are using another distributions, the steps may or may not be different.

Open a final and use the following control:

            ssh-keygen          

You should see an output similar this:

            Generating public/individual rsa key pair. Enter file in which to save the key (/user_home/.ssh/id_rsa):          

Press the enter key and go with the default selection. You lot may exist asked to enter a countersign to secure your SSH key. If yous set a password, you lot'll have to enter it every time you endeavor to brand a SSH connection using the generated SSH key. You may or may not prepare a password for the SSH key.

10 Actionable SSH Hardening Tips to Secure Your Linux Server

Worried about the security of your Linux server? Learn some easy to implement tips on securing SSH and make your Linux server more secure.

Adding public SSH key to GitLab

If you have created SSH central on your personal reckoner, you should find it in the .ssh directory under your habitation directory in well-nigh Linux distributions. Display its content with this command:

            true cat ~/.ssh/id_rsa.pub          

Copy the content of your public primal. Now log in to your GitLab business relationship, go to User Settings and look for SSH keys in the left sidebar. Alternatively, yous tin can just go to this folio when logged in.

You'll encounter a field for adding the public key. Just paste the key here. Give it a title to easily recognize which computer this cardinal belongs to. Unless you did something on your own, SSH keys don't take an expiry date by default. Then go out the expiry field untouched.

Done with everything? Hit the Add key button.

adding ssh key to GitLab

You lot can add together more one SSH keys. That'south normal if you have more one computer.

Check if you can push the code to GitLab now

So, you added your SSH key to your GitLab profile. Things should be good now. Time to verify it.

Try to push your code again. Encounter if information technology works. Normally, you should see an output similar this if information technology is successful:

            [email protected]:~/Documents/Local-Code$ git push button -u origin master 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 compression using upwardly to iv threads Compressing objects: 100% (122/122), done. Writing objects: 100% (127/127), 401.30 KiB | 6.37 MiB/s, done. Total 127 (delta fourteen), reused 0 (delta 0) remote: Resolving deltas: 100% (xiv/xiv), done. To https://gitlab.com/gitlab_account_username/gitlab_repository.git  * [new branch]      master -> master Branch 'chief' fix up to rails remote co-operative 'primary' from 'origin'.          

Still see mistake? Mind the difference betwixt GitLab profile username and the account username!

I learned it the hard way.

GitLab has 2 usernames: profile username and account username.

Yous can easily change the profile username without whatever consequences. Merely changing the account username tin can be catastrophic.

The account username is what you'll run across 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 contour 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 lawmaking to the repository. Unsurprisingly, it got denied fifty-fifty afterward adding the SSH key:

            [e-mail protected]:~/Documents/Local-Lawmaking$ git push -u origin main Username for 'https://gitlab.com': gitlab_profile_username Password for 'https://[email protected]':  remote: HTTP Bones: Access denied fatal: Authentication failed for 'https://gitlab.com/gitlab_account_username/gitlab_repository.git/'          

So, the play a trick on is to use the GitLab business relationship username here. When I did that, the push to the remote GitLab repository was successful.

Did information technology work for you?

Well, I shared my ordeal with pushing code to GitLab repository. I hope this helped y'all with the "fatal: Authentication failed" error too.

Did it work for you? Do let me know with a yeah or no in the annotate section.

patefropriat.blogspot.com

Source: https://linuxhandbook.com/gitlab-authentication-failed/

0 Response to "Repository Access Denied. Access via a Deployment Key Is Read-only. Bitbucket"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel