17

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?

1
  • Try use your own username git clone [email protected]:myName/repositoryName/ repoName Commented Jun 28, 2018 at 14:56

6 Answers 6

22

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
Sign up to request clarification or add additional context in comments.

1 Comment

it still throws bash ue@DESKTOP-EVCRRVA /cygdrive/c/Users/ue/.ssh $ ssh [email protected] The authenticity of host '[altssh.gitlab.com]:443 ([172.65.251.182]:443)' can't be established. ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '[altssh.gitlab.com]:443,[172.65.251.182]:443' (ECDSA) to the list of known hosts . [email protected]: Permission denied (publickey,keyboard-interactive).
7

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/

1 Comment

You can learn about modfying your config file here linuxize.com/post/using-the-ssh-config-file
5

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

Comments

4

You could try:

ssh [email protected]

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.

1 Comment

how can you please explain ?
1

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.

Comments

0

navigate to C:\Users\ .ssh

edit or create config file

Host User git Port run ssh -vT

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.