Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to clone any git repo even after adding ssh keys

Tags:

git

github

ssh

I am trying to clone a repo from github. To do that

  1. I have generated a ssh key using: ssh-keygen.

  2. Then I added the content of ~/.ssh/id_rsa.pub to my keys in github account.

Even after that I am unable to clone any repo. I am getting following error:

ssh_exchange_identification: read: Operation timed out
Please make sure you have the correct access rights
and the repository exists.

In this regard, I have gone through a few posts here, but unable to fix.

NOTE: This error I am facing even after removing SSH key from my github account.

EDIT: When I am doing "ssh -T [email protected]", I am getting the same error:

ssh_exchange_identification: read: Operation timed out

As suggested in: https://help.github.com/en/articles/error-permission-denied-publickey, while executing following commands:

 1. ssh-add -l ==> The agent has no identities.
 2. ssh-add -l -E md5 ==> The agent has no identities.
like image 948
Joy Avatar asked Dec 19 '25 21:12

Joy


2 Answers

You get this error for one of these 3 reasons:

  1. when you have authentication/authorization problems
  2. When you have an internet access problem
  3. SSh problems

Do the following:

first in your terminal run ssh -T [email protected] if you see your GitHub username in response. you know that you are authenticated properly if not...

first check internet access: make sure you can access GitHub by cloning a public repo (any repo) by SSH (not https). if you fail here you have problems with SSH or internet connection

if this step passed, try to clone one of your other private repos by ssh. if you failed. you have an authentication problem and your ssh key is wrong. (try again by https and compare the results)

if this step passed, try to clone this repo by https (not ssh). if you failed. you have an authorization problem and you have no access to this repo

like image 119
Mahdi Aryayi Avatar answered Dec 21 '25 10:12

Mahdi Aryayi


One of the solutions that worked for me was setting ssh config.

  1. Create and open config file: sudo nano ~/.ssh/config

  2. Add following lines and save:

Host github.com
Hostname ssh.github.com
Port 443
  1. Try running: ssh -T [email protected]

Now you can clone the repo.

like image 42
DarthCucumber Avatar answered Dec 21 '25 11:12

DarthCucumber