Quick Fix to Tackle “Please make sure you have the correct access rights and the repository exists”

Every programmer knows the importance of creating git, be it on GitHub or GitLab. The best thing about posting a project as a git is that you and your team can work on it remotely. You can also make it public to help other programmers simply understand the complex codes. Not even programmers, but the git can be seen by the non-programmers. It is also a good platform for students to get help from others git. When working on git, you may encounter various errors, and “Please make sure you have the correct access rights and the repository exists” is one of those.

This is one of the common errors that you may experience. We will provide valuable solutions to help you fix the error. Check out how you land in the error

How the error occurs

The cause of the error is the use of a git clone. You may end up with an error warning. Check out the command you use to clone the specific repository

git clone https://github.com/daxmann-tutorials/ck-git

Once you run this, you get the following error

Permission denied (publickey,password).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists

Let’s highlight the possible solution to fix it

Solutions to Fix “Please make sure you have the correct access rights and the repository exists”

The main issue is the authentication due to a change of location or a new gig with no access rights.  It also happens when trying to use two ssh keys in order to access two accounts. Check out the step-by-step solution

Step 1 – Make two ssh key pairs

The ssh key needs to be added to the ssh agent to solve the issue. Follow the below code to create twossh keys

ssh-keygen -t rsa -C "[email protected]"

Step 2 – Two ssh keys

The two keys can be created using the following command


Step 3 – Add the Following keys

ssh-add ~/.ssh/id_rsa_account2
ssh-add ~/.ssh/id_rsa_account1

To add the key list, you need this command:

ssh-add -l

To remove keys cached, use this command

ssh-add -D

Step 4 – Use ssh Config

cd ~/.ssh/
touch config

Step 5 – Add the code to the config file

#Github account1
Host github.com-account1
    HostName github.com
    User account1
    IdentityFile ~/.ssh/id_rsa_account1

#Github account2
Host github.com-account2
    HostName github.com
    User account2
    IdentityFile ~/.ssh/id_rsa_account2

Step 6 – Update .git/config file

The next step is to navigate the account 1 project. Follow the below command

[remote "origin"]
        url = [email protected]:account1/gfs.git

Update the host if another user invited you to their repository. Follow the below code

[remote "origin"]
            url = [email protected]:invitedByUserName/gfs.git

To navigate account 2, you need to update the host using the below command

[remote "origin"]
        url = [email protected]:account2/gfs.git

Step 7 – Update email and username separately

For account 1 project

git config user.name "account1"
git config user.email "[email protected]" 

For account 2

git config user.name "account2"
git config user.email "[email protected]"


We have discussed a step-by-step process to solve “Please make sure you have the correct access rights and the repository exists”. You need to follow the steps to efficiently get rid of the error warning. I hope it helps!

Reference Source: https://stackoverflow.com/questions/25927914/git-error-please-make-sure-you-have-the-correct-access-rights-and-the-reposito



Posted in Git

Leave a Reply

Your email address will not be published. Required fields are marked *