git push在gitlab中失败了

时间:2013-11-05 20:52:18

标签: git ssh gitlab

  1. 我在/home/myuser/gitlab安装了Gitlab。
    1. 我创建了一个代表test
    2. 按照说明,我添加了一个远程git@localhost:root/testing.git
  2. 我发现我的ssh连接有问题。这是我的/home/myhome/.ssh/config文件

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

    当我运行git push -u origin master时,我被要求输入我的密码。但是,在收到此消息后立即

    Connection closed by ::1
    

    致命:无法从远程存储库中读取。

    请确保您拥有正确的访问权限 存储库存在。

    我哪里错了?这是我的ssh连接

    更新:我停止了sshd并且已经停止了sshd -d(在我的/home/myhome中),然后ssh -T mylocalhost,我进入了ssh -d输出

    debug1: sshd version OpenSSH_6.2, OSSLShim 0.9.8r 8 Dec 2011
    debug1: read PEM private key done: type RSA
    debug1: private host key: #0 type 1 RSA
    debug1: read PEM private key done: type DSA
    debug1: private host key: #1 type 2 DSA
    debug1: rexec_argv[0]='/usr/sbin/sshd'
    debug1: rexec_argv[1]='-d'
    debug1: Bind to port 22 on 0.0.0.0.
    Server listening on 0.0.0.0 port 22.
    debug1: Bind to port 22 on ::.
    Server listening on :: port 22.
    debug1: fd 6 clearing O_NONBLOCK
    debug1: Server will not fork when running in debugging mode.
    debug1: rexec start in 6 out 6 newsock 6 pipe -1 sock 9
    debug1: inetd sockets after dupping: 5, 5
    Connection from ::1 port 51579
    debug1: Client protocol version 2.0; client software version OpenSSH_6.2
    debug1: match: OpenSSH_6.2 pat OpenSSH*
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.2
    debug1: permanently_set_uid: 75/75 [preauth]
    debug1: list_hostkey_types: ssh-rsa,ssh-dss [preauth]
    debug1: SSH2_MSG_KEXINIT sent [preauth]
    debug1: SSH2_MSG_KEXINIT received [preauth]
    debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none [preauth]
    debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none [preauth]
    debug1: SSH2_MSG_KEX_DH_GEX_REQUEST received [preauth]
    debug1: SSH2_MSG_KEX_DH_GEX_GROUP sent [preauth]
    debug1: expecting SSH2_MSG_KEX_DH_GEX_INIT [preauth]
    debug1: SSH2_MSG_KEX_DH_GEX_REPLY sent [preauth]
    debug1: SSH2_MSG_NEWKEYS sent [preauth]
    debug1: expecting SSH2_MSG_NEWKEYS [preauth]
    debug1: SSH2_MSG_NEWKEYS received [preauth]
    debug1: KEX done [preauth]
    debug1: userauth-request for user git service ssh-connection method none [preauth]
    debug1: attempt 0 failures 0 [preauth]
    debug1: PAM: initializing for "git"
    debug1: PAM: setting PAM_RHOST to "localhost"
    debug1: userauth-request for user git service ssh-connection method publickey [preauth]
    debug1: attempt 1 failures 0 [preauth]
    debug1: test whether pkalg/pkblob are acceptable [preauth]
    debug1: temporarily_use_uid: 1111/20 (e=0/0)
    debug1: trying public key file /Users/git/.ssh/authorized_keys
    debug1: fd 6 clearing O_NONBLOCK
    debug1: matching key found: file /Users/git/.ssh/authorized_keys, line 1
    Found matching RSA key: e9:70:a8:96:1c:a5:b4:b0:58:b0:b8:22:6f:9b:98:bb
    debug1: restore_uid: 0/0
    Postponed publickey for git from ::1 port 51579 ssh2 [preauth]
    debug1: userauth-request for user git service ssh-connection method publickey [preauth]
    debug1: attempt 2 failures 0 [preauth]
    debug1: temporarily_use_uid: 1111/20 (e=0/0)
    debug1: trying public key file /Users/git/.ssh/authorized_keys
    debug1: fd 6 clearing O_NONBLOCK
    debug1: matching key found: file /Users/git/.ssh/authorized_keys, line 1
    Found matching RSA key: e9:70:a8:96:1c:a5:b4:b0:58:b0:b8:22:6f:9b:98:bb
    debug1: restore_uid: 0/0
    debug1: ssh_rsa_verify: signature correct
    debug1: do_pam_account: called
    Failed publickey for git from ::1 port 51579 ssh2
    debug1: audit_event: unhandled event 6
    Access denied for user git by PAM account configuration [preauth]
    debug1: do_cleanup [preauth]
    debug1: monitor_read_log: child log fd closed
    debug1: do_cleanup
    debug1: PAM: cleanup
    debug1: Killing privsep child 17748
    debug1: audit_event: unhandled event 12
    

    顺便说一下,每次运行git命令时,都会收到消息

    ssh: Could not resolve hostname mylocalhost: nodename nor servname provided, or not known
    fatal: Could not read from remote repository.
    

    更新2

    当我运行ssh mylocalhost时,我收到了好消息Welcome to GitLab, Administrator!。但是,我得到以下输入

    debug2: channel 0: rcvd eof
    debug2: channel 0: output open -> drain
    debug2: channel 0: obuf empty
    debug2: channel 0: close_write
    debug2: channel 0: output drain -> closed
    debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
    debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
    debug2: channel 0: rcvd eow
    debug2: channel 0: close_read
    debug2: channel 0: input open -> closed
    debug2: channel 0: rcvd close
    debug3: channel 0: will not send data after close
    debug2: channel 0: almost dead
    debug2: channel 0: gc: notify user
    debug2: channel 0: gc: user detached
    debug2: channel 0: send close
    debug2: channel 0: is dead
    debug2: channel 0: garbage collecting
    debug1: channel 0: free: client-session, nchannels 1
    debug3: channel 0: status: The following connections are open:
      #0 client-session (t4 r0 i3/0 o3/0 fd -1/-1 cc -1)
    
    Transferred: sent 3284, received 3480 bytes, in 0.4 seconds
    Bytes per second: sent 7501.3, received 7949.0
    debug1: Exit status 0` 
    

    并在我的GitLab日志中

    Started GET "/api/v3/internal/allowed?key_id=4&action=git-receive-pack&ref=_any&project=testing" for 127.0.0.1 at 2013-11-07 16:48:00 +0100
    

1 个答案:

答案 0 :(得分:3)

如果您使用SCP-like syntax作为ssh网址,那么,考虑到您的〜/ .ssh / config,该网址应为:

git remote set-url origin mylocalhost:root/testing.git

假设您已在GitLab帐户页面中添加了公钥(〜/ .ssh / id_rsa.pub):

https://intranet.5amsolutions.com/download/attachments/24610136/Git3.png?version=1&modificationDate=1349371375213

并且访问保护是正确的

OP Newben报告(in the comments):

  

我必须转到我的osx共享偏好设置面板并手动设置用户远程访问权限