Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with Git: "ssh: connect to host gitlab port 22: connection refused"

Tags:

git

ssh

push

gitlab

i am writing my bachelors thesis at a company and got access to gitlab from the admin, but I am new to Git. I created a new project for my thesis. I already had a folder with some stuff on my computer. I used the following commands in the git bash (as recommended by gitlab):

git init
git remote add origin git@gitlab:USER/TITLE.git
git add [stuff]
git commit
git push -u origin master

Committing was successfull, but the last command created the error

"ssh: connect to host gitlab port 22: Connection refused fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists."

I tried to switch to port 443, because apparently, that is a thing.

ssh -T -p 443 [email protected]

That got me:

"The authenticity of host '[altssh.gitlab.com]:443 ([35.190.168.187]:443)' can't be established.
ECDSA key fingerprint is [...].
Are you sure you want to continue connecting (yes/no/[fingerprint])?"

After typing yes:

"Warning: Permanently added '[altssh.gitlab.com]:443,[35.190.168.187]:443' (ECDSA) to the list of known hosts.
[email protected]: Permission denied (publickey)."

When going back to port 22, the connection timed out. The error after the push command is still the same.

According to canyouseeme.org, the ports 22 and 443 are not open.

I also tried to make new rules for the ports in the windows defender firewall menu.

Still the same error. I would really appreciate any help or ideas from you :)

Peter

like image 399
PeterD Avatar asked Sep 19 '25 05:09

PeterD


2 Answers

I solved it, it was not that hard. ssh does not work, everyone uses http here. I copied the wrong url from gitlab.

the command I had to use is:

git remote set-url origin http://gitlab/USER/PROJECT.git
like image 54
PeterD Avatar answered Sep 20 '25 18:09

PeterD


Check if you are not behind a VPN, I spent like half an hour before I thought about that.

like image 23
Alexander Avatar answered Sep 20 '25 18:09

Alexander