Git 快速搭建 Gitosis 服务器望指点.?

lb563 · 2014年04月19日 · 最后由 lb563 回复于 2014年04月20日 · 4260 次阅读

在新的 Centos 机器上做一个 Gitosis 服务器。.搭建失败,不确实配置端口问题。

初始化工作

  1. 安装Gitosis脚本

  2. 新建 git 用户并在目录下生成 gitosisrepositories 两个目录。

  3. git clone [email protected]:gitosis-admin.git # 10.207.137.222 内网 ip 且和Gitosis在一台机器上。

遇到的问题

前两步都没有问题,问题在第三步。执行结果后输出

Initialized empty Git repository in /tmp/gitosis-admin/.git/
Connection closed by 10.207.137.222
fatal: The remote end hung up unexpectedly

以下是/etc/ssh/ssh_config的配置信息

#Host *
#   ForwardAgent  yes
#   ForwardX11 no
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
    Port 36000
#   Protocol 2,1
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
Host *
        GSSAPIAuthentication yes
# If this option is set to yes then remote X11 clients will have full access
# to the original X11 display. As virtually no X11 client supports the untrusted
# mode correctly we set this to yes.
        ForwardX11Trusted yes
# Send locale-related environment variables
        SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES 
        SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT 
        SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE
        SendEnv XMODIFIERS

端口起在 36000 上。是不是还有一些其它配置没有做好。

需要怎么配置才能让 git clone 成功。

Google 尝试

http://stackoverflow.com/questions/5767850/git-on-custom-ssh-port # 没有成功

http://stackoverflow.com/questions/3596260/git-remote-add-with-other-ssh-port # 没有成功

http://serverfault.com/questions/218256/specify-ssh-port-for-git #也没有成功

使用sshdebug 来调试输出

ssh -v [email protected]
OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010
debug1: Reading configuration data /data/home/app100722374/.ssh/config
debug1: Applying options for 10.207.137.222
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 10.207.137.222 [10.207.137.222] port 36000.
debug1: Connection established.
debug1: identity file /data/home/app100722374/.ssh/identity type -1
debug1: identity file /data/home/app100722374/.ssh/id_rsa type 1
debug1: identity file /data/home/app100722374/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '[10.207.137.222]:36000' is known and matches the RSA host key.
debug1: Found key in /data/home/app100722374/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,keyboard-interactive
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
debug1: An invalid name was supplied
debug1: An invalid name was supplied
debug1: Next authentication method: publickey
debug1: Trying private key: /data/home/app100722374/.ssh/identity
debug1: Offering public key: /data/home/app100722374/.ssh/id_rsa
debug1: Remote: Forced command: gitosis-serve app100722374@VM-137-222-tlinux
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Remote: Forced command: gitosis-serve app100722374@VM-137-222-tlinux
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
Connection closed by 10.207.137.222

内容有点长,只是为提供更多的信息。

额...请直接用 gitlab 部署吧,别折腾 gitosis 和 gitolite 了。

二楼正解,gitosis 被 gitolite 代替了,gitolite 被 gitlab 代替的,所以新建服务还是直接 gitlab 吧。

#2 楼 @ruohanc #3 楼 @ericguo 好的去试一试gitlab

需要 登录 后方可回复, 如果你还没有账号请 注册新账号