Google Compute Engine 中 GitLab 上的 Git 推/拉失败 [英] Git push/pull fails on GitLab in Google Compute Engine

查看:18
本文介绍了Google Compute Engine 中 GitLab 上的 Git 推/拉失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我还可以使用 Web 界面登录 GitLab,并将 SSH 密钥添加到我的个人资料中.到现在为止还挺好.但是,当我尝试推送或拉取新的示例存储库时,我会收到以下消息:

权限被拒绝(publickey、gssapi-keyex、gssapi-with-mic).致命:无法从远程存储库中读取.请确保您拥有正确的访问权限并且存储库存在.

我已经删除了我的本地 SSH 配置,所以它不会干扰.我需要设置某种 SSH 隧道吗?我错过了什么?

更新:清除我的本地 ~/.ssh 文件夹,并重新生成一个 SSH 密钥(我已添加到我在 GitLab 中的配置文件中)会产生以下错误:

从 {GITLAB_IP_ADDRESS} 收到断开连接:2:git 的身份验证失败太多致命:无法从远程存储库中读取.请确保您拥有正确的访问权限并且存储库存在.

更新 2: 似乎 GitLab 可能已经有了解决方案:运行 sudo gitlab-ctl reconfigure.见这里: 根据 这条评论

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

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

sudo yum -y install policycoreutils-python # 安装`semanage`工具sudo semanage fcontext -a -t ssh_home_t "/var/opt/gitlab/.ssh/authorized_keys" # 允许非标准的ssh_home_t

在此处查看完整主题:

谷歌云引擎.权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic)

I've installed GitLab on Google Compute Engine using "Click to Deploy" from the project interface. The deployment is successful after a few minutes. I can SSH into the instance, and muck around with it as expected.

I can also log in to GitLab using the web interface, and add SSH keys to my profile. So far, so good. However, when I attempt to push or pull to a new example repository, I receive this message:

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.

I've removed my local SSH config so it doesn't interfere. Do I need to setup an SSH tunnel of some sort? What am I missing?

UPDATE: Wiping out my local ~/.ssh folder, and regenerating an SSH key (which I've added to my profile in GitLab) produces the following error:

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.

UPDATE 2: It seems GitLab may already have a solution: run sudo gitlab-ctl reconfigure. See here: https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md#git-ssh-access-stops-working-on-selinux-enabled-systems

解决方案

You need to create an SSH tunnel to communicate with GitLab.

1. Log into your development server as your user, and create a key.

ssh-keygen -t rsa

Follow the steps, and create a passcode (that you can remember) as you'd need this to pull and push code from/to GitLab.

2. Now that you've created your key, we can copy it;

cat id_rsa.pub

Copy the output of that command (including ssh-rsa), and add it to your GitLab profile. (http://my-gitlab-server.com/profile/keys/new).

3. Ensure you have the correct privilege to the project(s)

Ensure you are at role developer at the very least. (Screengrab of roles: http://i.stack.imgur.com/DSSvl.jpg)

4. Now, copy the project link

Go into your project, and find the SSH link in the top right;

5. Now back to your development server

Navigate to your directory where you'd like to work, and run the following;

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

Where <<project_url>> is the link we copied in step 4.

You will be prompted your password (this is your ssh key password, not your server password) and to add the host to your known_hosts file. After that, the project will start to download and you can enjoy development.

I did these steps on a CentOS 6.4 machine with Digital Ocean. But they shouldn't differ from using Google CE.

Edit

Quote from Marty Penner answer as per this comment

Solved it! Thanks to @sxleixer and @Alexander Wenzowski for figuring this out.

Apparently, SELinux was interfering with a non-standard location for the .ssh directory. I needed to run the following commands on the Compute Engine instance:

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

See the full thread here:

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

这篇关于Google Compute Engine 中 GitLab 上的 Git 推/拉失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆