【发布时间】:2020-01-14 20:59:59
【问题描述】:
我正在做一个项目,需要将 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 密码和我的计算机登录密码都不是这里期望的密码。根据this question,我跑了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 问题的正确方向,那将非常有帮助。
【问题讨论】: