Search code examples
gitgitlabgitlab-ce

Cannot push to repository on self-managed GitLab server


I have installed GitLab CE on a CentOS (release 6.10) machine.

After creating the repository from GitLab interface on the browser, I would like to clone and push my changes to the repository.

I tried both cloning the repository and pushing the existing contents to the repository; however, the user password is not accepted although the user's SSH key is registered:

# git push -u origin master
[email protected]'s password: 
Permission denied, please try again.
[email protected]'s password: 
Permission denied, please try again.
[email protected]'s password: 
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: The remote end hung up unexpectedly

This is the information regarding the setup environment:

# 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:  [email protected]: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

This is what I get while trying to establish an SSH connection:

# ssh -vT [email protected]
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
[email protected]'s password: 
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
[email protected]'s password: 
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
Permission denied, please try again.
[email protected]'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


Solution

  • I figured out the issue.

    After adding the following lines to /etc/ssh/ssh_config and adding the user git to AllowUsers list in /etc/ssh/sshd_config, it no longer prompts for a password:

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