【问题标题】:ssh connection failing when pushing on a Gitlab repo推送 Gitlab 存储库时 ssh 连接失败
【发布时间】:2013-07-17 17:47:31
【问题描述】:

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

  1. 我创建了一个新项目
  2. 有人告诉我要创建一个我在/home/myuser/gitlab/test 中输入的 repo “测试”
  3. 我在/home/myuser/.ssh 中添加了一些 SSH 密钥
  4. 然后我在 /home/myuser/gitlab/test 中初始化了一个 Git 存储库。
  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/myuser/gitlab/.git/config 中设置了用户电子邮件和名称,(并在全局范围内设置它们只是为了测试)并且服务器从 @ 启动987654330@。有人知道这个错误来自哪里吗?

如果我运行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 <your home acct>

【问题讨论】:

  • @AloisMahdal 是的,我认为这是烫发问题。我要更新我的标题

标签: ruby-on-rails ruby git gitlab


【解决方案1】:

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

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

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

  • 还要检查您的 .ssh/config 文件的内容,该文件的格式似乎不正确。

看到这个example of a config file

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

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

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

【讨论】:

  • 当我运行ssh -T git@localhost 时,我得到了同样的信息:/home/myhome/.ssh/config line 4: garbage at end of line; "home".
  • 我已经用~/.ssh/config 文件的内容更新了我的帖子。是否可以为多个用户配置?顺便说一句,User &lt;your home acct&gt; 是什么意思?
  • @Newben ssh 配置文件的想法是定义一个条目“foobar”,它将设置正确的服务器名称(主机名)、ssh 私钥(IdentityFile)和 ssh 会话所在的用户被打开。我已经编辑了我的答案。这将允许执行“ssh foobar”(无需输入git@xxx,并且使用非标准的公钥/私钥文件)。您可以定义任意数量的条目,允许您使用不同的用户和密钥。
  • 感谢您提供如此完整的答案,事实是我将其放在了我的配置文件中:Host localhost Hostname localhost PORT 3000 User git IdentityFile /home/myuser/.ssh/id_rsa.pub,我现在得到了ssh: connect to host localhost port 22: Connection refused
  • @Newben 尝试使用 'Host mylocalhost 只是为了确保 shell 不会将 'localhost' 解释为 127.0.0.1,而是作为 ssh/config 文件中的条目。然后检查您的本地主机上的该端口上是否有运行 sshd(守护程序)。您甚至可以启动 sshd -d 来检查您的 ssh 守护程序是如何启动的、在哪个端口上以及在您执行 ssh mylocalhost 时它是否收到任何内容。
猜你喜欢
  • 1970-01-01
  • 2015-04-21
  • 2013-04-08
  • 2019-03-25
  • 2016-08-24
  • 1970-01-01
  • 2019-10-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多