由于之前克隆了私有 GitHub 存储库,我在将私有存储库克隆到我的 CPanel 服务器时遇到了一些问题。我在使用 ssh 访问之前克隆了它,一切顺利。但是,我需要克隆另一个也是私有的并且使用 ssh 访问的存储库。
我按照所有程序将私有存储库复制到 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
我尝试连接到第二个帐户的最后一条记录。
答案 0 :(得分: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
始终只是主机名,而不是 <git@github.com:SthefanyRangel/regionadmin.git>
因此,您的第一个 ~/.ssh/config
条目应该是(对于实际的 GitHub 用户名,已为其注册公共 SSH 密钥):
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