Bitbucket Permission Denied (Publickey). Fatal: Could Not Read From Remote Repository.
You tin can authenticate yourself with a Git repository using either a Secure Beat out (SSH) key or a password. If you employ an SSH key and fail to configure that fundamental correctly, you lot'll meet the "Permission denied (publickey). fatal: Could not read from remote repository" fault.
In this guide, we discuss what this fault means. We besides discuss why yous may run into it and walk through an case so you can figure out how to solve this mistake.
Permission denied (publickey). fatal: Could not read from remote repository
SSH keys permit y'all authenticate with a Git repository without worrying about passwords. SSH is the aforementioned method of authentication that Linux servers employ to allow remote access.
SSH keys rely on public-private key authentication. For this method of authentication to work, your Git server must be configured with a public key, and your local machine must have the corresponding private primal.
Git clients like Atlassian and GitHub require that you lot upload your public key to their dashboards before you tin can utilise SSH authentication.
An Case Scenario
We've configured a local repository called ck-git. This repository contains one file: README.md.
We are going to link this repository to one on GitHub. To do this, we tin utilise the git remote command:
git remote add together origin git@github.com:career-karma-tutorials/ck-git.git
We have created a remote called "origin" to which nosotros can push our lawmaking. To push our local repository to GitHub, we can utilise the git push command:
81% of participants stated they felt more than confident nearly their tech task prospects after attending a bootcamp. Get matched to a bootcamp today.
The average bootcamp grad spent less than six months in career transition, from starting a bootcamp to finding their offset job.
git push -u origin main
This control uploads our changes to the master branch on our "origin" remote server. Let's run into what happens when we run the command:
Permission denied (publickey). fatal: Could not read from remote repository. Delight make certain you take the correct access rights and the repository exists.
We have encountered an error.
Solution #i: Bank check that your fundamental is used
Earlier we explore any other solutions, we should make certain that our key is being used to brand an SSH connexion. We can do this by using the ssh-add command:
eval "$(ssh-amanuensis -due south)" ssh-add together -l -E md5
The first command starts the SSH agent on your computer. The adjacent control lists all of the SSH keys that are configured on your machine.
At present that you have this list of SSH keys, check to come across if they match the 1 y'all've uploaded to GitHub, Bitbucket, or another version control system you use. If at least one of the keys on the list does non match, you need to add one of them to your version control arrangement.
Solution #two: Adding an SSH key
You may encounter this error if you accept non yet added an SSH key to your version control business relationship. The way in which you add an SSH key to a Git repository varies depending on the version control arrangement y'all apply.
For GitHub, y'all can use the post-obit steps:
- Note down your SSH key using the commands nosotros discussed in Solution #one
- Open GitHub, click on your avatar on the top-right corner and click "Settings"
- Click "SSH and GPG keys" in the sidebar
- Add together an SSH key to your business relationship
To add an SSH key to your account, you must first take a cardinal. Yous tin can generate one using the post-obit commands:
ssh-keygen -t rsa -b 4096 -C "electronic mail@email.com" ssh-add -Chiliad ~/.ssh-/id_rsa
Substitute "id_rsa" for the name of your key if y'all changed information technology when you were prompted to choose a key name from the first command.
Then, run the following command to see your public key:
This volition give you lot the cord you demand to upload into your version control system.
Crusade #three: Using the wrong method of authentication
We've configured our repository to use an SSH URL:
git remote add origin git@github.com:career-karma-tutorials/ck-git.git
Using this URL ways nosotros must use SSH authorized key pairs to cosign with our repository.
This is only possible if we have set SSH authentication. If you desire to configure your repository with HTTP, which lets you utilize a username and password to authenticate, y'all must use an HTTP URL:
git remote add origin https://github.com/career-karma-tutorials/ck-git
When nosotros push button our code to our remote server, nosotros'll exist asked for our Git username and password. This will requite us a chance to cosign using HTTP instead of SSH.
Conclusion
The "Permission denied (publickey). fatal: Could not read from remote repository" fault is caused by an issue with the way in which you authenticate with a Git repository.
To solve this error, make sure your primal is being used on your Git business relationship. If it is non, add your key to Git. If you exercise non have a public cardinal and want to use ane to cosign with Git, you'll need to create ane.
You may want to opt to authenticate using HTTP if you practice not want to use SSH. You can do this by using a HTTP URL equally the remote URL for your repository.
"Career Karma entered my life when I needed information technology most and quickly helped me friction match with a bootcamp. Two months subsequently graduating, I establish my dream chore that aligned with my values and goals in life!"
Venus, Software Engineer at Rockbot
Source: https://careerkarma.com/blog/git-permission-denied-publickey/
0 Response to "Bitbucket Permission Denied (Publickey). Fatal: Could Not Read From Remote Repository."
Post a Comment