首页 > 解决方案 > 多个(超过 1 个)私有 Github 存储库连接到 cpanel - 无法创建第二个 cpanel 存储库

问题描述

我在 Github 中有多个私人仓库。当我尝试设置第二个 cpanel 存储库(使用规定的 Git 版本控制和 SSH 密钥/对配置说明)时,第二个存储库失败并出现可怕的 128 错误:

我的主机帐户上有两个子域(将它们视为“测试”和“产品”),每个子域都指向自己的子文件夹(在 cpanel 文件管理器中),并且每个子域在 Github 中都有自己的私有存储库。第一个子域(测试)效果很好 - 每次都成功地从 Github 向我的网站提供拉取请求。但是当我尝试设置第二个 cpanel 存储库时,会发生上述错误 - 似乎无法动摇这个。

我验证了密钥对配置正确(cat ~/.ssh/id_rsa.pub 和 cat ~/.ssh/id_rsa3.pub),并发现它们正确加载到 cpanel 的 .ssh/ 文件夹中。我什至对我的 Github 存储库进行了三次检查,以确保它们每个都有自己的部署密钥(来自 cpanel 的公共 SSH 密钥)。

任何指导将不胜感激!

非常感谢!!担

标签: gitgithubsshcpanel

解决方案


根据 VonC 回答的评论链,在 cPanel 中创建 Git 存储库时,您不能使用 ssh 配置中的别名。这让生活变得艰难。

但由于某种原因,您可以通过 API 运行等效命令。因此,请改为进行 API 调用。我们想要的 API 端点是/VersionControl/create,记录在api.docs.cpanel.net/openapi/cpanel/operation/VersionControl::create中。

进行 API 调用的最快方法是将如下所示的 URL 直接插入浏览器。

https://hostname.example.com:2083/cpsess##########/execute/VersionControl/create?type=git&name=example&repository_root=/home/user/public_html/example&source_repository={"remote_name": "origin","url":"github_alias:github-user/yourreponame.git"}

将 cpsess########## 替换为您在登录 cPanel 界面时分配的任何键。

然后你会有一个看起来像这样的 ssh 配置:

Host github_alias
  Hostname github.com
  User git
  IdentityFile ~/.ssh/github_key1
  Port 22
Host github_alias2
  Hostname github.com
  User git
  IdentityFile ~/.ssh/github_key2
  Port 22

推荐阅读