gpt4 book ai didi

gitlab - Git 推/拉在 Google Compute Engine 中的 GitLab 上失败

转载 作者:行者123 更新时间:2023-12-02 01:48:31 25 4
gpt4 key购买 nike

我已使用项目界面中的“单击部署”在 Google Compute Engine 上安装了 GitLab。几分钟后部署成功。我可以通过 SSH 连接到该实例,并按预期处理它。

我还可以使用 Web 界面登录 GitLab,并将 SSH key 添加到我的个人资料中。到目前为止,一切都很好。但是,当我尝试推送或拉取新的示例存储库时,我收到以下消息:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.

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

我已经删除了本地 SSH 配置,因此它不会造成干扰。我需要设置某种 SSH 隧道吗?我错过了什么?

更新:清除我的本地 ~/.ssh 文件夹并重新生成 SSH key (我已将其添加到 GitLab 中的个人资料中)会产生以下错误:

Received disconnect from {GITLAB_IP_ADDRESS}: 2: Too many authentication failures for git
fatal: Could not read from remote repository.

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

更新2:看来GitLab可能已经有了解决方案:运行sudo gitlab-ctl reconfigure。参见这里:https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#git-ssh-access-stops-working-on-selinux-enabled-systems

最佳答案

您需要创建 SSH 隧道来与 GitLab 通信。

1。以您的用户身份登录到您的开发服务器,并创建一个 key 。

ssh-keygen -t rsa

按照步骤操作,并创建一个密码(您可以记住),因为您需要使用它从 GitLab 提取代码或将代码推送到 GitLab。

2。现在您已经创建了 key ,我们可以复制它;

cat id_rsa.pub

复制该命令的输出(包括 ssh-rsa ),并将其添加到您的 GitLab 配置文件中。 (http://my-gitlab-server.com/profile/keys/new)。

3。确保您拥有项目的正确权限

确保您至少是角色开发者。 (角色截图:/image/DSSvl.jpg)

4。现在,复制项目链接

进入您的项目,并在右上角找到 SSH 链接;

enter image description here

5。现在回到您的开发服务器

导航到您想要工作的目录,然后运行以下命令;

$ git init
$ git remote add origin <<project_url>>
$ git fetch

哪里 <<project_url>>是我们在第 4 步中复制的链接。

系统将提示您输入密码(这是您的 ssh key 密码,而不是您的服务器密码)并将主机添加到您的 known_hosts文件。之后,项目将开始下载,您就可以享受开发了。

我在装有 Digital Ocean 的 CentOS 6.4 计算机上执行了这些步骤。但它们应该与使用 Google CE 没有什么不同。

编辑

引自Marty Penner按照 this comment 回答

解决了!感谢@sxleixer 和@Alexander Wenzowski 解决了这个问题。

显然,SELinux 干扰了 .ssh 目录的非标准位置。我需要在 Compute Engine 实例上运行以下命令:

sudo yum -y install policycoreutils-python # Install the `semanage` tool
sudo semanage fcontext -a -t ssh_home_t "/var/opt/gitlab/.ssh/authorized_keys" # Allow the nonstandard ssh_home_t

在此处查看完整线程:

Google Cloud Engine. Permission denied (publickey,gssapi-keyex,gssapi-with-mic)

关于gitlab - Git 推/拉在 Google Compute Engine 中的 GitLab 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26427165/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com