git push 在 gitlab 中失败

标签 git ssh gitlab

  1. 我已经在 /home/myuser/gitlab 中安装了 Gitlab。
    1. 我创建了一个代表测试
    2. 按照说明,我添加了一个远程 git@localhost:root/testing.git

我发现我的 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

最佳答案

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

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 ):

I had to go to my osx shared preferences panel and set manually the users remote access perms.

关于git push 在 gitlab 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19798726/

相关文章:

git - 你如何停止跟踪 Git 中的远程分支?

git - 即使没有更改存储库,Jenkins 也会持续在 Windows slave 上构建

bash - 通过 docker-compose 拉取 ssh-client 容器

mysql - 无法从 MySQL Workbench 建立远程连接

git rev-parse HEAD 返回非零退出状态 128

maven - Gitlab CI maven 生成源失败并显示 400

git - 在 git 命令中使用 git shell 别名

Git LFS 要求每个跟踪文件的密码

java - 从java在远程机器上运行linux命令

gitlab - 如何获取某个 CI_PIPELINE_IID 的 GitLab 管道?