Reputation: 677
i try to get Gitlab with SSH working, but it won't.
I have done following steps:
1 ) generate ssh-key
ssh-keygen -t rsa -C "[email protected]" -b 4096
2 ) named the key "id_rsa" in folder /Users/myUserName/.ssh/
3) copied the key via
pbcopy < ~/.ssh/id_rsa.pub
4) insert the key into gitlab
When i now try to clone a repository i receive the following error:
$ git clone [email protected]:myName/repositoryName/ repoName
Cloning into 'repoName'...
ssh: connect to host gitlab.com port 22: Operation timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What is going wrong?
Upvotes: 17
Views: 66240
Reputation: 267
navigate to C:\Users\ .ssh
edit or create config file
Host User git Port run ssh -vT
Upvotes: 0
Reputation: 339
In my case, my EC2 instance is restarted and the IP address got changed(due to restart), but I forget to update my server IP in ".gitlab-ci.yml" file. Once I have updated the correct IP, pipeline is successful.
PS: I am practising a use case in "Techworld with Nana" course.
Upvotes: 1
Reputation: 226
I found myself with the same problem.
As Adrian Dymorz describe you can check if you have access to Gitlab through SSH with the following command:
ssh [email protected]
You should receive a response like this:
...
Welcome to GitLab, <Gitlab ID Account>!
Shared connection to altssh.gitlab.com closed.
If not, then betarrabara should solve your issues BUT you should not provide your id_rsa but your id_rsa.pub instead:
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.pub
Upvotes: 21
Reputation: 124
I tried the above method but remove the .pub in last line because it said not correct format. And it's worked.
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Upvotes: 5
Reputation: 1382
GitLab.com runs a second SSH server that listens on the commonly used port 443, which is unlikely to be firewalled.
All you have to do is edit your ~/.ssh/config
and change the way you connect to GitLab.com.
Host gitlab.com
Hostname altssh.gitlab.com
User git
Port 443
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.pub
Source: https://about.gitlab.com/2016/02/18/gitlab-dot-com-now-supports-an-alternate-git-plus-ssh-port/
Upvotes: 7
Reputation: 967
You could try:
It should open a connection which gets closed immediately.
If you get a timeout, you may are behind a firewall which blocks the connection. In that case, you should add a rule which allows you to connect.
Upvotes: 4