I'm trying to connect to ubuntu 16.04 local development server from a different ip through ssh, the server has gitlab and has a public hostname. example.com/2222. My gitlab ssh port is 9409

my .ssh/config

Host server
    ProxyCommand ssh -W example.com:2222 username@server
    IdentityFile ~/.ssh/id_rsa

Now to clone

git clone ssh://server:9409/username/test.git

It says

Cloning into 'test'...
Bad owner or permissions on /.ssh/config
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Also is -W needed in my case? I still don't know what ssh -W does


I did chmod 600 now I get ssh_exchange_identification: Connection closed by remote host

I still think my config file has a problem somewhere

  • duplicate of serverfault.com/questions/253313/… – Simon B Apr 10 '18 at 8:51
  • 1
    It's not even going to read your config if it has bad permissions. The contents are irrelevant until those are fixed. – muru Apr 10 '18 at 10:08
  • @SimonB please read my edit – Lynob Apr 10 '18 at 10:23
  • @muru please read my edit – Lynob Apr 10 '18 at 10:23
  • 1
    Ok. If your Gitlab ssh port is 9049, why are you using 2222 in your ProxyCommand? – muru Apr 10 '18 at 10:26

Based on the clarifications, let me first note that there are three possibly different usernames involved here:

  1. The username for example.com, say user1.
  2. The username registered on Gitlab, which may or may not be the same as the one above, say user2. This is the Gitlab account for which you added the public key, for example.
  3. The username for Gitlab's SSH access, which is probably git, and almost certainly not the username registered inside Gitlab. This depends on Gitlab's configuration.

Given that, I think this is how your ssh config should look:

Host  zoltan
  Port 9049
  ProxyCommand ssh -W %h:%p -p 2222 user1@example.com

And for cloning, you should do:

 git clone git@zoltan:user2/project.git

The IdentityFile you're specifying is used by default anyway, so that can be omitted unless there are other conflicting settings in your SSH config.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.