ssh connection failing when pushing on a Gitlab re

2019-05-30 04:46发布

问题:

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>

回答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.