简体   繁体   English

在谷歌计算引擎中的centos 7上设置git服务器

[英]setting up git server on centos 7 in google compute engine

I have a google compute engine instance on which I want to setup a git server which will be accessed by developers to push and pull development source code. 我有一个谷歌计算引擎实例,我想在其上设置一个git服务器,开发人员可以访问它来推送和开发源代码。 I have created a user called git for accessing the repository. 我创建了一个名为git的用户来访问存储库。 Then added every developers public key to the server /home/git/.ssh/authorized_keys file. 然后将每个开发人员公钥添加到服务器/home/git/.ssh/authorized_keys文件中。

Below are the configurations I issued to do the above mentioned 以下是我为完成上述操作而发布的配置

$ useradd –m /home/git –s /usr/bin/git-shell git

Install git on the server 在服务器上安装git

$ yum install git -y

Configuring ssh authorization for the users 为用户配置ssh授权

$ cd /home/git
$ mkdir .ssh && chmod 700 .ssh
$ touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys

Append developers ssh keys to the authorized_keys file on the server 将开发人员的ssh密钥附加到服务器上的authorized_keys文件

Create a bare repository for the code 为代码创建一个裸存储库

$ mkdir /opt/git/project.git
$ cd /opt/git/project.git
$ git init - -bare - -shared=group

Edit the existing permissions 编辑现有权限

$ chgrp -R developers .

Testing the configurations 测试配置

$ git clone ssh://git@IP_ADDRESS/opt/git/project.git

when i try to clone the repository, it issues an error: 当我尝试克隆存储库时,它会发出错误:

git clone屏幕截图

Note: I tried the above setup on a physical server and it worked perfectly and didn't need to configure ssh keys on the system. 注意:我在物理服务器上尝试了上述设置,它运行良好,不需要在系统上配置ssh密钥。 So I am wondering whether it compute engine the problem. 所以我想知道它是否计算引擎问题。

At some point I thought it was an issue of permission on the /opt directory, I thus modified the permissions to read/write for others, but it didn't work. 在某些时候我认为这是/ opt目录的权限问题,因此我修改了其他人的read/write权限,但它没有用。 Also I further created a repository but in the home dir of the user git, still it didn't work. 此外,我进一步创建了一个存储库,但在用户git的主目录中,它仍然无法正常工作。

I need some help to solve this issue of authentication of user git. 我需要一些帮助来解决用户git的身份验证问题。

Solution

i found the trick behind. 我找到了诀窍。 Actually the machine i was using to clone the project was running windows 8 OS. 实际上我用来克隆项目的机器是运行Windows 8操作系统。 So the trick was to copy the id_rsa.* (pub and ppk) files in C:\\Users\\USERNAME\\.ssh to the git directory at C:\\Users\\USERNAME\\git\\.ssh . 因此,关键是要复制id_rsa.*酒馆和PPK)在文件C:\\Users\\USERNAME\\.ssh到GIT目录在C:\\Users\\USERNAME\\git\\.ssh

With this everything works perfectly. 有了这一切,一切都很完美

i found the trick behind. 我找到了诀窍。 Actually the machine i was using to clone the project was running windows 8 OS. 实际上我用来克隆项目的机器是运行Windows 8操作系统。 So the trick was to copy the id_rsa.* (pub and ppk) files in C:\\Users\\USERNAME\\.ssh to the git directory at C:\\Users\\USERNAME\\git\\.ssh . 因此,关键是要复制id_rsa.*酒馆和PPK)在文件C:\\Users\\USERNAME\\.ssh到GIT目录在C:\\Users\\USERNAME\\git\\.ssh

With this everything works perfectly. 有了这一切,一切都很完美

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM