1

I have installed GitLab. Suppose I installed it in /home/myuser/gitlab.

  1. I created a new project
  2. I was told to create a repo "test" I put in /home/myuser/gitlab/test
  3. I added some SSH key in /home/myuser/.ssh
  4. Then I initialized a Git repo in /home/myuser/gitlab/test.
  5. Following instructions, I added a remote git@localhost:root/testing.git but when I try to push, I get this error message:
$ git push -u origin master
ssh: connect to host localhost 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 installed GitLab in OS X and I have other SSH keys in /home/myhome/.ssh, I have set up the user email and name inside /home/myuser/gitlab/.git/config, (and set those globally just for testing) and the server is launched from /home/myuser/gitlab. Does anybody have an idea where this error comes from?

If I run ssh git@localhost, I get

/home/myhome/.ssh/config line 4: garbage at end of line; "home".

where in this file I have some settings for a remote server for another project. I think it is the problem but I don't really know how to fix it.

Update : Here's the content of my ~/.git/config file

Host remote_test_server
Hostname remote_test_user@ftp.remote_test_server
IdentityFile ~/.ssh/id_rsa_stf.pub
User <your home acct>
epsilones
  • 11,279
  • 21
  • 61
  • 85

1 Answers1

1

/home/myhome/.ssh/config line 4: garbage at end of line; "home".

That would prevent any ssh command to properly function, because of a parasite echo done by the remote session.

  • Check your .profile or other .rc files, and see if any echo is done in those.
    Or at least, test with ssh -T git@localhost, in order to disable any TTY allocation.

  • check also the content of your .ssh/config file, which doesn't seem to be properly formatted.

See this example of a config file:

User should be the login name of the account used for the ssh session on the rmeote server.
It should not be the homedir path.

IdentityFile should reference the private key (~/.ssh/id_rsa_stf), not the public one!

Hostname should reference the remote server 'ftp.remote_test_server', not the user@remoteServer.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • when I run `ssh -T git@localhost` I get the same message : `/home/myhome/.ssh/config line 4: garbage at end of line; "home".` – epsilones Jul 18 '13 at 17:36
  • I have updated my post with the content of the `~/.ssh/config` file. Is it possible to configure for multiple user ? Btw, what does mean `User ` ? – epsilones Jul 18 '13 at 17:42
  • 1
    @Newben the idea of the ssh config file is to define an entry "foobar" which will set the right server name (Hostname), ssh private key (IdentityFile), and user under which the ssh session is opened. I have edited my answer. That would allow to do '`ssh foobar`' (without having to put `git@xxx`, and with non-standard public/private keys files). You can define as many entry as you want, allowing you to use different user and keys. – VonC Jul 18 '13 at 17:52
  • thank you for this very complete answer, the fact is that I put this on my config file : `Host localhost Hostname localhost PORT 3000 User git IdentityFile /home/myuser/.ssh/id_rsa.pub` and I get now `ssh: connect to host localhost port 22: Connection refused` – epsilones Jul 18 '13 at 18:14
  • @Newben try with '`Host mylocalhost` just to be sure the shell doesn't interpret '`localhost`' as 127.0.0.1, but as an entry in the ssh/config file. Then check you do have an sshd (daemon) running on your localhost on that port. You can even launch an `sshd -d` to check how your ssh daemon is launched, on which port, and if it receives anything when you do your `ssh mylocalhost`. – VonC Jul 18 '13 at 18:21
  • ok you're wright, the `ssh daemon was not running`! Now, when I run `git push -u origin master`, I am told that `fatal: 'root/testing.git' does not appear to be a git repository`. What does mean `root` in `git@localhost:root/testing.git`. Should I add `git remote set-url git@localhost:3000/testing.git` ? – epsilones Jul 18 '13 at 18:33
  • @Newben or you can do `git remote set-url origin mylocalhost:testing.git`, since a ssh config file is there to allow you to use *shorter* ssh url! But first, make sure `ssh mylocalhost` works. – VonC Jul 18 '13 at 18:38
  • when I run `ssh -v mylocalhost` I am told that the connection is established on the right port, the key is recognized but I have this line `debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request` and the outputs ends by `ssh_exchange_identification: Connection closed by remote host`. Is it normal ? When I push I get `ssh: Could not resolve hostname mylocalhost: nodename nor servname provided, or not known fatal: Could not read from remote repository.` – epsilones Jul 18 '13 at 18:46
  • @Newben Bad request means your sshd doesn't run on the port you have specified. – VonC Jul 18 '13 at 19:12
  • Sorry, i still have the same problem. When I ssh connect to one remote test server I have, it works just fine. Supposing I had trouble to listen some specific port, and following some SO posts, I changed the my `ssh.plist` file (that configures on `OSX` the `ssh`daemon), to impose the `3000` port listening, but now the `Webrick` server that runs `Gitlab` won't work anymore... – epsilones Jul 19 '13 at 13:03
  • @Newben if you impose a special port, are you sure your sshd monitor that port? And did you specify that ssh port in your `gitlab.yml` config file? – VonC Jul 19 '13 at 13:30