Jessica Chambers
Jessica Chambers

Reputation: 1326

Gitlab: unable to connect with SSH key or HTTPS

I am working on a project and need to clone the Gitlab project to my computer. I am running CentOS 6 in a VM.I do not have access to the Gitlab server or its information as it belongs to a third party.

The SSH problem

I have tried multiple ways of creating ssh keys, including but not limited to:

ssh-keygen -t rsa -C "Gitlab" -b 4096
ssh-keygen -t rsa -C "GitLab" -b 2048
ssh-keygen

At no point did I ever set a passphrase. I copied the /home/jchambers/.ssh/id_rsa.pub to Gitlab in the appropriate way, but this was my result:

$ git clone git@localhost:Project/Project_stuff.git
Initialized empty Git repository in /home/jchambers/Project/Project_stuff/.git/
git@localhost's password: 
Permission denied, please try again.

I never set a passphrase, and neither my Gitlab password nor my computer login password are the password it is expecting here. Per this question, I ran ssh -vT git@localhost:

$ ssh -vT git@localhost
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 localhost [::1] port 22.
debug1: Connection established.
debug1: identity file /home/jchambers/.ssh/identity type -1
debug1: identity file /home/jchambers/.ssh/identity-cert type -1
debug1: identity file /home/jchambers/.ssh/id_rsa type 1
debug1: identity file /home/jchambers/.ssh/id_rsa-cert type -1
debug1: identity file /home/jchambers/.ssh/id_dsa type -1
debug1: identity file /home/jchambers/.ssh/id_dsa-cert type -1
debug1: identity file /home/jchambers/.ssh/id_ecdsa type -1
debug1: identity file /home/jchambers/.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-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 'localhost' is known and matches the RSA host key.
debug1: Found key in /home/jchambers/.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,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
Credentials cache file '/tmp/krb5cc_502' not found

debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_502' not found

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_502' not found

debug1: Next authentication method: publickey
debug1: Offering public key: /home/jchambers/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/jchambers/.ssh/identity
debug1: Trying private key: /home/jchambers/.ssh/id_dsa
debug1: Trying private key: /home/jchambers/.ssh/id_ecdsa
debug1: Next authentication method: password
git@localhost's password: 

and updated these permissions:

chmod 700 /home/git/.ssh
chmod 600 /home/git/.ssh/authorized_keys

I don't understand what isn't working in the public key authentication part.

EDIT*

Per the answers I received, I changed the hostname in the command, making it:

$ git clone [email protected]:Project/Project_stuff.git
Initialized empty Git repository in /home/jchambers/Project/Project_stuff/.git/
ssh: connect to host my-gitlab.gitlab-platform.net port 22: Connection timed out
fatal: The remote end hung up unexpectedly

I also ran this again, but the connection always seems to time out on this:

$ 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 my-gitlab.gitlab-platform.net [12.34.567.89] port 22.
debug1: connect to address 12.34.567.89 port 22: Connection timed out
ssh: connect to host my-gitlab.gitlab-platform.net port 22: Connection timed out

The HTTPS problem

As the SSH situation seemed fruitless, I attempted the HTTPS method. It didn't work initially so per another question, I made the following changes:

sudo yum install ca-certificates
update-ca-trust force-enable

This made no difference. This is what I get when I try to clone via HTTPS:

$ git clone https://my-gitlab.gitlab-platform.net/gitlab/Project/Project_stuff.git
Initialized empty Git repository in /home/jchambers/Project/Project_stuff/.git/
error:  while accessing https://my-gitlab.gitlab-platform.net/gitlab/Project/Project_stuff.git/info/refs

fatal: HTTP request failed

My internet connection, though behind a proxy, works fine otherwise (I can install via yum, for example, and use the web browser). The Gitlab project does require a login so maybe I need to input that somewhere?

If anyone can point me in the right direction for either the SSH problem or the HTTPS one, that would be very helpful.

Upvotes: 0

Views: 1085

Answers (1)

favoretti
favoretti

Reputation: 30207

I believe that your GitLab's SSH port is not 22. In your URL using SSH you're defaulting to port 22, mu guess would be that it's your server's SSH daemon that's answering, rather than GitLab - hence your public key doesn't work. Same for HTTPS, I assume default port is not 443.

If you can share more details on how your GitLab is installed and ran - it would be possible to give you more pointers.

Upvotes: 1

Related Questions