Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github SSH works but clone using ssh fails

I came across a weird issue while cloning a git repository using ssh. I have the ssh setup:

ssh -T [email protected]
Hi yusufali2205! You've successfully authenticated, but GitHub does not provide shell access.

I am using the right clone url and have access to the repo I want to clone. But getting error:

➤ git clone [email protected]:<some-org>/<repo>.git
Cloning into 'project'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

There is no other message to debug what is wrong with my ssh setup or git configuration.

like image 395
Yusufali2205 Avatar asked May 17 '17 20:05

Yusufali2205


People also ask

Why I Cannot clone a repository from GitHub?

If you're unable to clone a repository, check that: You can connect using HTTPS. For more information, see "HTTPS cloning errors." You have permission to access the repository you want to clone.

Why is my Git clone not working?

Make sure that the path in the git clone call is correct. If you have an authorization error, have an administrator check the ACLs in Administration > Repositories > <repoName> > Access. Have an administrator check the bare repo in the GitCentric storage directory.


1 Answers

I found out there was an entry in my .gitconfig which was replacing ssh with https.

[url "https"]
    insteadOf = git

I might have accidentally added this entry while using some tool. So the clone command was actually using the url [email protected]:<some-org>/<repo>.git

After removing the above entry from .gitconfig the problem was resolved.

like image 197
Yusufali2205 Avatar answered Oct 06 '22 18:10

Yusufali2205