Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Gitlab:无法使用SSH密钥或HTTPS连接_Git_Ssh_Https_Gitlab - Fatal编程技术网

Gitlab:无法使用SSH密钥或HTTPS连接

Gitlab:无法使用SSH密钥或HTTPS连接,git,ssh,https,gitlab,Git,Ssh,Https,Gitlab,我正在做一个项目,需要将Gitlab项目克隆到我的计算机上。我在虚拟机中运行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复制到G

我正在做一个项目,需要将Gitlab项目克隆到我的计算机上。我在虚拟机中运行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-vTgit@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: 
我不明白公钥认证部分有什么不起作用

编辑*

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

$ 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
我的internet连接虽然在代理之后,但在其他情况下工作正常(例如,我可以通过
yum
安装,并使用web浏览器)。Gitlab项目确实需要登录,所以我可能需要在某个地方输入它


如果有人能为我指出SSH问题或HTTPS问题的正确方向,那将非常有帮助。

我相信您的GitLab的SSH端口不是22。在使用SSH的URL中,默认为端口22,我猜是服务器的SSH守护进程在应答,而不是GitLab,因此公钥不起作用。对于HTTPS也是一样,我假设默认端口不是443


如果您可以分享有关如何安装和运行GitLab的更多详细信息,那么就有可能为您提供更多的指针。

我无法访问它的运行方式(由另一家公司运行),但我将尝试更改端口:)如何访问GitLab的URL以获得web UI?哦,等一下。如果它是由另一家公司运行的,那么您的SSH URL通常是不正确的,因为您正试图连接到
localhost
。这意味着您希望git与您在同一台机器上执行命令时在同一台机器上运行。要从远程机器进行克隆,您需要一个类似
git@hostname_of_gitlab:Project/Project_stuff.git
好的,所以我再次尝试了ssh,并调整了主机名,我可以确认它是通过端口22运行的,但仍然无法正常工作,如果您可以访问GitLab的UI,我将使用插图编辑我的问题,在它的“克隆”按钮中可以使用一个URL。要调试出这样的问题是不可能的。您提到您使用了代理,要使https克隆工作,您需要先导出
https\u proxy
env变量,然后再使用git命令,如
export https\u proxy=“address\u of\u your\u proxy:port”
$ 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