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

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

问题描述

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

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.

我还可以使用Web界面登录到GitLab,并将SSH密钥添加到我的配置文件中.到目前为止,一切都很好.但是,当我尝试推送或拉到新的示例存储库时,会收到以下消息:

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.

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

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?

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

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.

更新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

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

推荐答案

您需要创建SSH隧道才能与GitLab通信.

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

ssh-keygen -t rsa

按照步骤操作,并创建一个密码(您可以记住),因为您需要使用该密码来将代码从GitLab中拉入/推入.

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

cat id_rsa.pub

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

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

至少要确保您是角色开发者. (角色的屏幕截图: http://i.stack.imgur.com/DSSvl.jpg)

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

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

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

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

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

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

其中<<project_url>>是我们在第4步中复制的链接.

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

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

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.

我在带有Digital Ocean的CentOS 6.4机器上完成了这些步骤.但是它们与使用Google CE没什么不同.

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

Marty Penner 的答案是根据

Quote from Marty Penner answer as per this comment

解决了!感谢@sxleixer和@Alexander Wenzowski弄清楚了这一点.

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

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

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

在此处查看完整线程:

Google云引擎.权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic)

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

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