2013-07-19 209 views
1

我打开一些问题,我有点问过之前,但现在问题似乎是相当链接到sshSSH连接到GIT失败

  1. 我在/home/myuser/gitlab中安装了Gitlab。
  2. 我创建了一个代表test
  3. 以下说明中,我添加了一个远程[email protected]:root/testing.git

Gitlab的服务器在端口3000上运行)。现在,当我尝试推,我收到此错误信息:

$ git push -u origin master 
    ssh: Could not resolve hostname mylocalhost: nodename nor servname provided, or not known 
fatal: Could not read from remote repository. 

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

现在,我发现有一个问题,我的SSH连接。这是我的/home/myhome/.ssh/config文件

Host mylocalhost 
Hostname localhost 
PORT 3000 
User git 
IdentityFile /home/myuser/.ssh/id_rsa.pub 

当我运行ssh mylocalhost我得到这个消息

ssh_exchange_identification: Connection closed by remote host 

冗余模式,似乎连接正确的端口上建立,但这里的porcess失败debug1: ssh_exchange_identification: HTTP/1.1 400 Bad Request。 我试图更新我的/System/Library/LaunchDaemons/ssh.plist(我正在使用OSX)转发端口收听3000但后来GitlabWebrickRails服务器将不再运行。 L试图改变git remote set-url origin mylocalhost:testing.git

+0

[git remote add with other ssh port](http:// stackoverflow.com/questions/3596260/git-remote-add-with-other-ssh-port) – Joe

回答

0

最后,我想清楚是什么问题。我必须正确设置~/.ssh/config文件

Host mylocalhost 
    Hostname localhost 
//I deleted a line specifying the PORT to 3000 
    User git 
    IdentityFile /home/myuser/.ssh/id_rsa //It was previously set to /home/myuser/.ssh/id_rsa.pub 

然后我重新安装了一个关键,但我仍然有一些问题。最后,将文件/home/myuser/.ssh/id_rsa的perm设置为644,它工作得很好。有关详细信息,我发现在网络上搜索一些设置可以与700600 chmod perm一起使用,但对我来说644没有窍门

+1

听起来不错。我之前写过有关ssh文件权限的文章:http://stackoverflow.com/a/3712619/6309 – VonC

+0

非常感谢! – Newben

0

Gitlab的HTTP接口可能在端口3000上运行,但SSH并没有在那里运行来将存储库推送到那里。

ssh: connect to host localhost port 22: Connection refused的消息意味着SSH客户端无法在localhost端口22上连接到SSH服务器我会确保你已经installed gitlab correctly和Gitlab运行正常。也确保SSH服务器正在运行,并且能够接受端口连接22

+0

哦,好难过,我已经更新了我的帖子,现在的错误提示信息不一样 – Newben

0

你不能指望,如果你使用的是完全指定的URL

[email protected]:root/testing.git 

至于I have explained to you before使用的端口号3000:

ssh配置文件的思想是定义一个条目“foobar”,它将设置正确的服务器名称(Hostname),ssh私钥(IdentityFile)以及在其下打开ssh会话的用户。
这将允许做'ssh foobar'(而不必将[email protected],并与非标准的公钥/私钥文件)。
您可以根据需要定义多个条目,允许您使用不同的用户和密钥。

所以你不能用[email protected]来定义原点。您必须键入:

git remote add origin mylocalhost:testing.git 

或者,如果原点已经确定了,你需要改变它的URL:

git remote set-url origin mylocalhost:testing.git 

(没有“root/”你不要在前面指定任何路径gitlab回购:gitlab将演绎回购的完整路径)

但是你需要确保您的sshd启动3000端口,并gitlab.yml包含端口号。


ssh: Could not resolve hostname mylocalhost: nodename nor servname provided, or not known 

这意味着SSH找不到~/.ssh/config,在它mylocalhost条目。
确保文件存在。

你的previous question放在~/.git/config,这与ssh无关。

+0

对不起,我有一个副本粘贴pb ,错误消息不再相同。事实上,当我更改'sshd'端口时,这里解释:http://serverfault.com/questions/18761/how-to-change-sshd-port-on-mac-os-x,我的'Webrick'' Rails的服务器不会再运行... – Newben

+0

@新本好吧。我编辑了我的答案。 – VonC

+0

当然,我有它(我也verufy'sudo'用户可以看到它)。这是它是如何是主机mylocalhost 主机名localhost 端口3000 用户git IdentityFile/home/myuser/.ssh/id_rsa.pub'顺便说一句,当我启动'ssh -v mylocalhost'时,连接建立与正确的'HOSTNAME '并在右边'PORT' – Newben