【问题标题】:Can't clone gitlab repo via ssh on aws ec2无法通过 aws ec2 上的 ssh 克隆 gitlab 存储库
【发布时间】:2017-03-31 14:42:37
【问题描述】:

这个问题好像很常见,但是找了好久也没找到解决办法。

我无法克隆托管在 aws ec2 上的 gitlab 实例上的存储库。

Clonage dans 'angular2'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

我尝试为我的 ssh 使用配置文件但没有结果。

这里是 ssh -vT 命令的输出

OpenSSH_7.2p2 Ubuntu-4ubuntu2.1, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to gitlab.com [52.167.219.168] port 22.
debug1: Connection established.
debug1: identity file /home/chd/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/chd/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/chd/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/chd/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/chd/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/chd/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/chd/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/chd/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: Remote protocol version 2.0, remote software version  
OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to gitlab.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw
debug1: Host 'gitlab.com' is known and matches the ECDSA host key.
debug1: Found key in /home/chd/.ssh/known_hosts:3
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/chd/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/chd/.ssh/id_dsa
debug1: Trying private key: /home/chd/.ssh/id_ecdsa
debug1: Trying private key: /home/chd/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).

我准确地说我没有 aws 实例。

感谢您的帮助。

【问题讨论】:

  • 我没有使用AWS,但前几天遇到了类似的问题。我的问题的这个答案可能会对您有所帮助:stackoverflow.com/a/43085700/2562819
  • 好吧,我没有告诉我我使用的是 linux mint,所以我不担心 Windows 凭据管理器。
  • 我的链接中的第二个要点呢?您是否已确认您的帐户中是否保存了 SSH 密钥?
  • 嗯,是的,我账户里注册的key和我的.ssh/id_rsa.pub里的key是一样的
  • 您使用的是私有仓库还是公共仓库?

标签: git ssh amazon-ec2 gitlab git-clone


【解决方案1】:

服务器不接受您的私钥:

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/chd/.ssh/id_rsa
debug1: Authentications that can continue: publickey

确保/home/chd/.ssh/id_rsa.pub 在 gitlab.com SSH 密钥中。

【讨论】:

  • 是的,我输入了好的公钥(在文件 id_rsa.pub 和我的 gitlab 帐户中相同)
【解决方案2】:

将远程 url 从 ssh 更改为 https
使用 git remote origin set-url &lt;your https url&gt; 更改初始化 git repo 的目录

【讨论】:

  • Gitlab实例不支持Https
  • 一般。您使用的是自托管版本还是其他版本?
  • 似乎是配置gitlab实例的方式。正如我所说,我没有这方面的能力。
  • 好的,做一件事——去亚马逊实例,写ssh-keygen。只需按 Enter 2-3 次。你会得到类似this
    的东西,只需从终端复制路径(就像在屏幕截图中一样) - /Users/...../.ssh/id_rsa.pub 现在在你的 ssh 实例类型 cat &lt;THE COPIED PATH&gt;
    复制输出
    转到 gitlabs 配置文件设置 > 添加 ssh 密钥 > 粘贴它,保存它,它会工作
  • 我已经做到了。我试过很多次。这在这里不起作用,我不知道为什么。这才是重点。我准确地说我有另一个 gitlab 实例,我通过 ssh 运行连接没有问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-03-04
  • 2021-09-09
  • 2014-11-01
  • 1970-01-01
  • 2011-05-24
  • 1970-01-01
  • 2019-12-02
相关资源
最近更新 更多