Tuesday, September 10, 2019

Github | Could not read from remote repository error while cloning repo with ssh URL

Problem:

When trying to clone a repo from SSH url (e.g. git@github.com:repo-account/my-project.git), sometimes you may encounter an error like below:


Cloning into 'C:\user\projects\my-project\ssh-code\test\dotcom-my-repo'...
fatal: Could not read from remote repository.

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

Root Cause:

This happens when the request for clone is not supplied with proper public ssh key (which must be white listed at github.com) or clone command is not able to grab it.

Solution:

In such scenarios ensure following things:

1. Ensure public ssh key is  added to github account
2. Instead of using any git UI tool, open git "bash" window

 

3. If you have ssh public key generated already and want to use same for the repo checkout then skip this step otherwise create a new ssh key - https://help.github.com/en/enterprise/2.18/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

4. If you have just one ssh key for all projects then simply run below command in bash window:
      git clone git@github.com:repo-account/my-project.git
    In case you get into issues, try creating a fresh ssh key and add it to github account.

If you have more than one ssh key and want to use specific key for this checkout then run below command:
GIT_SSH_COMMAND="ssh -i C:/Users/vivmishr/.ssh/abc" git clone git@github.com:repo-account/my-project.git

Hope it works!

No comments:

Post a Comment

CDN | Clearing Cloudflare cache

In order to clear Cloudflare cache automatically via code, follow below steps: 1. Develop Custom TransportHandler Develop a custom Trans...