【问题标题】:connect to GIT repository gives error peer certificate invalid连接到 GIT 存储库给出错误对等证书无效
【发布时间】:2020-12-27 19:20:46
【问题描述】:

我的公司已迁移到新的 GITHUB 存储库。在我的 Linux 开发服务器上,我试图连接到新的 git 存储库以克隆它。我有一个部署工具,可以从 GIT 存储库中获取软件并自动部署。

但是,我与新存储库的新连接不起作用

$ git clone https://githubxxxxx.com/xxxxxxx/myrepo.git
Cloning into 'myrepo'...
fatal: unable to access 'https://githubxxxxx.com/xxxxxxx/myrepo.git/': Peer's certificate issuer has been marked as not trusted by the user.

我想我已经做了我想做的一切:

  • 我为 SSH 创建了一个新密钥
  • 我将密钥存储在 GIT 存储库中

我对我的笔记本电脑执行了相同的程序,并且成功了。

如果我更改 sslVerify 的全局属性

git config --global http.sslVerify false

然后我可以连接和克隆,但是每次我都必须输入用户和密码,这是没有意义的。

有人知道我是否错过了这里的任何一步吗?我还需要设置其他全局变量吗?

如果我对存储库执行ssh -v,我发现我可以进行身份​​验证。

debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/ftpfdm/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 535
debug1: Authentication succeeded (publickey).
Authenticated to githubxxxxx.com (via proxy).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: proc
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
PTY allocation request failed on channel 0
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi x329097! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Connection to githubxxxxx.com closed.

更新

如果我通过 ssh 尝试,我会通过远程主机关闭连接

$ git clone ssh://githubxxxxx.com:mygroup/myrepo.git
Cloning into 'myrepo'...
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

新更新

这可以代替。有谁知道为什么它以这种方式工作,而不是ssh://,实际上是通过 ssh 进行的克隆。我正要发布解决方案作为答案,但我认为这是不对的,因为我不知道为什么这种方式有效。

git clone git@githubxxxxx.com:group/myrepo.git

【问题讨论】:

  • 当您通过 https:// 连接时,您不是通过 SSH 连接。将您的网址切换到 ssh 网址:ssh://git@…
  • @knittl,如果我这样做,我会被拒绝连接。我试过了
  • 试试git@github…:group/project.git(主机部分后面的:很重要)GitHub 可以选择为您生成这些 URL
  • 我更新了问题。如果我尝试你的方法,我得到了新的错误
  • 我发现了错误。它没有ssh://。但是,我不知道为什么。

标签: git github ssh ssl-certificate


【解决方案1】:

对等的证书颁发者已被用户标记为不信任。

这纯粹是一个 HTTPS 问题,与 SSH 无关。

你需要做的:

如果您使用 SSH URL,则始终需要使用远程用户“git”,这就是 git@githubxxxxx.com:group/myrepo.git 起作用的原因。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-19
    • 1970-01-01
    • 2014-07-08
    • 1970-01-01
    • 2017-08-04
    • 2018-02-14
    • 2019-05-12
    • 1970-01-01
    相关资源
    最近更新 更多