簡體   English   中英

Gitlab:無法使用 SSH 密鑰或 HTTPS 連接

[英]Gitlab: unable to connect with SSH key or HTTPS

我正在做一個項目,需要將 Gitlab 項目克隆到我的電腦上。 我在 VM 中運行 CentOS 6。我無權訪問 Gitlab 服務器或其信息,因為它屬於第三方。

SSH 問題

我嘗試了多種創建 ssh 密鑰的方法,包括但不限於:

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

我從來沒有設置過密碼。 我復制了/home/jchambers/.ssh/id_rsa.pub到Gitlab在適當的方式,但是這是我的結果:

$ 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.

我從來沒有設置過密碼,我的 Gitlab 密碼和我的電腦登錄密碼都不是它在這里期望的密碼。 根據這個問題,我運行了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: 

並更新了這些權限:

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

我不明白什么在公鑰認證部分不起作用。

編輯*

根據我收到的答案,我更改了命令中的主機名,使其:

$ git clone jessica.chambers@my-gitlab.gitlab-platform.net: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

我也再次運行了這個,但連接似乎總是超時:

$ ssh -vT jessica.chambers@my-gitlab.gitlab-platform.net
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

HTTPS 問題

由於SSH的情況似乎沒有結果,我嘗試了HTTPS的方法。 它最初不起作用,因此根據另一個問題,我進行了以下更改:

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

這沒有任何區別。 這是我嘗試通過 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

我的互聯網連接雖然在代理后面,但在其他方面工作正常(例如,我可以通過yum安裝並使用網絡瀏覽器)。 Gitlab 項目確實需要登錄,所以也許我需要在某處輸入?

如果有人可以為 SSH 問題或 HTTPS 問題指出正確的方向,那將非常有幫助。

我相信您的 GitLab 的 SSH 端口不是 22。在您使用 SSH 的 URL 中,您默認使用端口 22,我猜想是您的服務器的 SSH 守護進程在應答,而不是 GitLab - 因此您的公鑰不起作用。 HTTPS 也一樣,我假設默認端口不是 443。

如果您可以分享有關如何安裝和運行 GitLab 的更多詳細信息 - 可以為您提供更多指導。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM