Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ssh: connect to host gitlab.com port 22: Network is unreachable

I'm trying to reach the Gitlab server to clone a repo in a Ubuntu 20.10 computer, but I always get the message:

ssh: connect to host gitlab.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.

So, I've tried to run the command ssh -T [email protected], but I've got the message:

ssh: connect to host gitlab.com port 22: Network is unreachable

I've tried in another computer with Ubuntu 20.04 and it worked.

Anyone can help me with this?

like image 210
LuisFelipe Avatar asked Dec 15 '20 02:12

LuisFelipe


People also ask

Is there an alternative port 22 for GitLab?

For GitLab there's an alternative to using port 22, check out this article: about.gitlab.com/blog/2016/02/18/… In general, some ISP block traffic on specific ports, same thing that happens in public networks like in hotels.

Why can't I SSH to GitHub?

If the issue persists with other services ( ssh -Tv [email protected] ), then SSH URLs are not allowed for you. Use an HTTPS URL. But if on the same network, another server does work, then double-check the firewall rules for your particular machine. One might block SSH, while the other not. 1.) You are on a network which blocks traffic to port 22.

What is the hostname of GitLab?

Host gitlab.com Hostname altssh.gitlab.com User git Port 443 PreferredAuthentications publickey IdentityFile ~/.ssh/id_rsa An error occurred while loading designs. Please try again.

Why can't I connect to Port 22?

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link! 1.) You are on a network which blocks traffic to port 22. Trying your connection from another network or device would be the best way to quickly test for this.


2 Answers

I would never be able to use SSH URL for any public Git repository hosting service (github.com, gitlab.com, ...) in a work environment.

If the issue persists with other services (ssh -Tv [email protected]), then SSH URLs are not allowed for you. Use an HTTPS URL.

But if on the same network, another server does work, then double-check the firewall rules for your particular machine. One might block SSH, while the other not.
(ufw status verbose)

like image 194
VonC Avatar answered Sep 24 '22 06:09

VonC


If you can't use ssh right now,You can use HTTPS instead with:

git remote set-url origin <Clone HTTPS address>
like image 24
Mevil Avatar answered Sep 24 '22 06:09

Mevil