git - 无法推送到 self 管理的 GitLab 服务器上的存储库

标签 git gitlab gitlab-ce

我已在 CentOS(版本 6.10)计算机上安装了 GitLab CE。

从浏览器上的 GitLab 界面创建存储库后,我想克隆我的更改并将其推送到存储库。

我尝试克隆存储库并将现有内容推送到存储库;但是,尽管用户的 SSH key 已注册,但用户密码仍不被接受:

# git push -u origin master
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6e09071a2e09071a020f0c400d0b001a011d58431d0b1c180b1c4002010d0f02" rel="noreferrer noopener nofollow">[email protected]</a>'s password: 
Permission denied, please try again.
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="33545a4773545a475f52511d50565d475c40051e4056414556411d5f5c50525f" rel="noreferrer noopener nofollow">[email protected]</a>'s password: 
Permission denied, please try again.
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1b7c726f5b7c726f777a7935787e756f74682d36687e696d7e69357774787a77" rel="noreferrer noopener nofollow">[email protected]</a>'s password: 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: The remote end hung up unexpectedly

这是有关设置环境的信息:

# gitlab-rake gitlab:env:info

System information
System:     CentOS 6.10
Current User:   git
Using RVM:  no
Ruby Version:   2.7.2p137
Gem Version:    3.1.4
Bundler Version:2.1.4
Rake Version:   13.0.1
Redis Version:  5.0.9
Git Version:    2.29.0
Sidekiq Version:5.2.9
Go Version: unknown

GitLab information
Version:    13.6.7
Revision:   4d1fc8bce72
Directory:  /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: PostgreSQL
DB Version: 11.10
URL:        http://gitlab.centos6-server.local
HTTP Clone URL: http://gitlab.centos6-server.local/some-group/some-project.git
SSH Clone URL:  <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bfd8d6cbffd8d6cbd3dedd91dcdad1cbd0cc8992ccdacdc9dacd91d3d0dcded3" rel="noreferrer noopener nofollow">[email protected]</a>:some-group/some-project.git
Using LDAP: no
Using Omniauth: yes
Omniauth Providers: 

GitLab Shell
Version:    13.13.1
Repository storage paths:
- default:  /var/opt/gitlab/git-data/repositories
GitLab Shell path:      /opt/gitlab/embedded/service/gitlab-shell
Git:        /opt/gitlab/embedded/bin/git

这是我在尝试建立 SSH 连接时得到的结果:

# ssh -vT <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b8dfd1ccf889818a96898e80968e968d" rel="noreferrer noopener nofollow">[email protected]</a>
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.6.5 [192.168.6.5] port 22.
debug1: Connection established.
debug1: identity file /home/ayildiz/.ssh/identity type -1
debug1: identity file /home/ayildiz/.ssh/identity-cert type -1
debug1: identity file /home/ayildiz/.ssh/id_rsa type 1
debug1: identity file /home/ayildiz/.ssh/id_rsa-cert type -1
debug1: identity file /home/ayildiz/.ssh/id_dsa type -1
debug1: identity file /home/ayildiz/.ssh/id_dsa-cert type -1
debug1: identity file /home/ayildiz/.ssh/id_ecdsa type -1
debug1: identity file /home/ayildiz/.ssh/id_ecdsa-cert 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-sha1 none
debug1: kex: client->server aes128-ctr hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<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
The authenticity of host '192.168.6.5 (192.168.6.5)' can't be established.
RSA key fingerprint is f6:af:9c:dd:5c:68:ba:26:5d:64:e5:44:5b:50:b6:c8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.6.5' (RSA) to the list of known hosts.
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,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Next authentication method: publickey
debug1: Trying private key: /home/ayildiz/.ssh/identity
debug1: Offering public key: /home/ayildiz/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/ayildiz/.ssh/id_dsa
debug1: Trying private key: /home/ayildiz/.ssh/id_ecdsa
debug1: Next authentication method: password
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="15727c6155242c273b24232d3b233b20" rel="noreferrer noopener nofollow">[email protected]</a>'s password: 
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f0979984b0c1c9c2dec1c6c8dec6dec5" rel="noreferrer noopener nofollow">[email protected]</a>'s password: 
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89f918cb8c9c1cad6c9cec0d6ced6cd" rel="noreferrer noopener nofollow">[email protected]</a>'s password: 
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

Account Settings - SSH Keys

最佳答案

我发现了这个问题。

将以下行添加到 /etc/ssh/ssh_config 并将用户 git 添加到 /etc/ssh/sshd_config 中的允许用户列表后>,它不再提示输入密码:

Host gitlab.centos6-server.local 
        RSAAuthentication yes 
        Preferredauthentications publickey 
        IdentityFile ~/.ssh/id_rsa

关于git - 无法推送到 self 管理的 GitLab 服务器上的存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75904019/

相关文章:

Git 通过 HTTP 推送两次要求输入密码

GIT、私有(private)子模块和 PHPFog

git - Gitlab CE 的高内存使用率

git - 错误: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 Bad Gateway fatal

gitlab - 无法在 GitLab 中更改用户项目限制

git svn 在非标准 svn 存储库布局上指定分支和标签

git - 从 git repo 中完全删除一个文件(从某个时间点开始)

ruby - gitlab-shell ssl 证书问题

docker - Gitlab 不加载新的 ssl 证书和 key

docker - docker运行后gitlab中的错误权限