Reputation: 467
After installing git on my new work computer, generating my ssh key and adding it on gitlab, I'm trying to clone a project but I get the following error:
ssh: connect to host <private-domain>.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I've also tried the command to just test the ssh connection with the verbose option and I get this:
$ ssh -Tvvv appgit@<private_domain>.com
OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/h/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/h/.ssh/known_hosts2'
debug2: resolving "<private_domain>.com" port 22
debug3: resolve_host: lookup <private_domain>.com:22
debug3: ssh_connect_direct: entering
debug1: Connecting to <private_domain>.com [<serv.ip.add.ress>] port 22.
debug3: set_sock_tos: set socket 4 IP_TOS 0x48
debug1: connect to address <serv.ip.add.ress> port 22: Connection timed out
ssh: connect to host <private_domain>.com port 22: Connection timed out
I know the domain exists, ping <private-domain>.com
works. I don't think it's a proxy issue because I'm not connecting with http or https.
None of the fixes in this answer changed anything. (I'm on Windows)
I've noticed that if I delete my keys in my ~/.ssh
folder, I get the same error, which makes me think this is a key problem and not a network problem. How can I be sure git is using the right key?
I've tried ssh-keygen -lf ~/.ssh/id_rsa -E md5
to see if the fingerprint matches the one on gitlab (it does) but that only gives me the one in the folder, not necessarily the one git uses. Git-gui Help>Show SSH Key
does show my key correctly though.
Upvotes: 7
Views: 77992
Reputation: 33
Got same issue, changed to another network and later reconnected to old network and it worked for me.
Sounds strange but yeah it worked!!
Got it from comments mentioned here: link
Upvotes: 1
Reputation: 1099
I solved this by deleting lines in ~/.ssh/known_hosts
.
Delete all host or ip related to the address.
www.####.com,xx.xx.xxx.xxx
10.15.##.## ssh-rsa AAAAB3NzaC1yc2EA
Upvotes: 2
Reputation: 658
If you are using gitlab which is running on custom domain you can do following
Host gitlab
HostName mycustomgitlabdomain.com
User my-git-user
IdentityFile ~/.ssh/my_private_key
Further, check following
Upvotes: -1
Reputation: 1324497
Double-check that:
the remote server at least answer on port 22
curl -v telnet://<private_domain>.com:22
(the connect to address <serv.ip.add.ress> port 22: Connection timed out
part seems to indicated that either the remote server does not listen, or the local server block any egress SSH connection)
appgit
: the default account usually used is git
.ssh -Tvvv git@<private_domain>.com
And make sure your key is using the default naming scheme (like ~/.ssh/id_rsa[.pub]
)
Upvotes: 6