【问题标题】:How to clone more than one private repository on CPanel如何在 CPanel 上克隆多个私有存储库
【发布时间】:2021-06-09 01:18:24
【问题描述】:

由于之前克隆的私有 GitHub 存储库,我在将私有存储库克隆到我的 CPanel 服务器时遇到了一些问题。我在使用 ssh 访问之前已经克隆了它,一切正常。但是,我需要克隆另一个也是私有的并且也使用 ssh 访问的 repo。

我按照之前的步骤将私有仓库复制到 CPanel 中。但是,我在访问权限方面遇到问题,收到与以下相同的消息:

ERROR: Repository not found.
fatal: Could not read from remote repository.

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

有没有办法克隆两个具有不同 ssh 密钥的私有存储库?如何克隆这些存储库而不会收到上述相同的消息?

提前致谢。

------------------------------------------ - - - 编辑 - - - - - - - - - - - - - - - - - - - - - - ---------

我在 .ssh 文件夹中的配置文件如下

Host region_admin
  HostName <git@github.com:SthefanyRangel/regionadmin.git>
  User regioye5@cs2006.webhostbox.net:2083
  IdentityFile ~/.ssh/id_rsa

Host renovafacil
  HostName <git@github.com>
  User regioye5@cs2006.webhostbox.net:2083
  IdentityFile ~/.ssh/id_rsa.rf
  
Host regionadmin-ra2
  HostName <git@github.com>
  User git
  IdentityFile ~/.ssh/region_admin

我连接到第二个帐户的尝试是最后一条记录。

【问题讨论】:

    标签: laravel git github ssh cpanel


    【解决方案1】:

    阅读文档“CPanel / How to Copy an Account with SSH Keys”后,如果 GitLab 存储库使用与第一个相同的帐户,您可能需要第二个密钥。

    如果没有,请尝试:

    git -c core.sshCommand='ssh -Tv' clone git@github:...
    

    这将使您了解考虑了哪些键。如果您的第二个键没有默认名称,则需要 ~/.ssh/config 才能指定它。

    您可以使用以下命令测试配置条目:

    ssh -T region_admin
    

    注意:Hostname 始终只是主机名,而不是 &lt;git@github.com:SthefanyRangel/regionadmin.git&gt;

    因此,您的第一个 ~/.ssh/config 条目应该是(对于已注册公共 SSH 密钥的实际 GitHub 用户名):

    Host region_admin
      HostName github.com
      User git
      IdentityFile ~/.ssh/id_rsa
    

    然后:

    cd /path/to/regionadmin
    git remote set-url origin region_admin:SthefanyRangel/regionadmin.git
    

    【讨论】:

    • 我试过这个命令,但是由于访问权限的原因它被中止了。我在 .ssh 文件夹中有配置文件,我不知道如何配置它,但我会制作和编辑,以便您验证
    • @SthefanyRangel 它应该显示一些调试输出,中止之前。
    • 我得到了以下信息:Cloning into 'regionadmin'... OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 debug1: Reading configuration data /home3/regioye5/.ssh/config ssh: Could not resolve hostname github\303: Name or service not known fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
    • @SthefanyRangel 是的,这是因为 Hostname 条目,正如我在编辑的答案中提到的那样。保持Hostnamegithub.com(没有 git,没有用户/repo)
    • 使用您在此处编写的命令,我一直得到相同的结果。 ssh: Could not resolve hostname &lt;github.com&gt;: Name or service not known 。您能举个例子,说明如何在配置文件中为该主机定义 ssh 配置吗?我将不胜感激
    猜你喜欢
    • 1970-01-01
    • 2015-07-24
    • 2021-09-16
    • 2021-02-04
    • 2014-10-30
    • 1970-01-01
    • 2019-12-26
    • 2019-10-01
    • 2011-11-16
    相关资源
    最近更新 更多