推送Gitlab仓库时ssh连接失败

我已经安装了GitLab 。 假设我在/home/myuser/gitlab安装了它。

  1. 我创建了一个新项目
  2. 有人告诉我创建一个repo“test”我放入/home/myuser/gitlab/test
  3. 我在/home/myuser/.ssh添加了一些SSH密钥
  4. 然后我在/home/myuser/gitlab/test初始化了一个Git repo。
  5. 按照说明,我添加了一个远程git@localhost:root/testing.git但是当我尝试推送时,我收到以下错误消息:
 $ 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. 

我在OS X中安装了GitLab,我在/home/myhome/.ssh有其他SSH密钥,我在/home/myhome/.ssh设置了用户电子邮件和名称,(并在全局范围内设置测试)并从/home/myuser/gitlab启动服务器。 有没有人知道这个错误来自哪里?

如果我运行ssh git@localhost ,我会得到

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

在这个文件中我有一些远程服务器的设置为另一个项目。 我认为这是问题,但我真的不知道如何解决它。

更新:这是我的~/.git/config文件的内容

 Host remote_test_server Hostname remote_test_user@ftp.remote_test_server IdentityFile ~/.ssh/id_rsa_stf.pub User  

/home/myhome/.ssh/config第4行:行尾的垃圾; “家”。

这会阻止任何ssh命令正常运行,因为远程会话完成了寄生回声。

  • 检查.profile或其他.rc文件,看看是否有任何回声。
    或者至少,使用ssh -T git@localhost测试,以禁用任何TTY分配。

  • 还要检查.ssh/config文件的内容,它似乎没有正确格式化。

请参阅配置文件的此示例 :

User应该是在rmeote服务器上用于ssh会话的帐户的登录名。
应该是homedir路径。

IdentityFile应该引用私钥( ~/.ssh/id_rsa_stf ), 而不是公共密钥!

Hostname应引用远程服务器“ ftp.remote_test_server ”,而不是用户@ remoteServer。