导航:首页 > IDC知识 > centos7搭建git服务器

centos7搭建git服务器

发布时间:2020-12-01 15:43:41

1、centos7搭建好gitlab,windows本地http://localhost:80不能访问

centos搭建的服务跟Windows的本地链路有毛关系

2、centos安装的git服务端可以后台运行吗

可以后台运行的,以gogs 为例

nohup ./gogs web 2>git_err.log 1>git.log &

2代表异常输出存放在git_err.log文件
1代表正常输出在存放在git.log文件

nohp yourCommand & 代表后台运行

3、如何在服务器上搭建git服务器

安装步骤此处略去。

END
安装CopSSH

安装步骤此处略去。
END
修改配置

修改CopSSH配置文件C:\Program Files\ICW\etc\sshd_config,确保如下行为非注释行,且设置为“no”:

END
生成用户帐号

1
在服务器上生成Windows用户,取消用户下次登录时须更改密码,设置密码永不过期:

2
将该用户隶属于GitUser组(如尚未生成改组,则先生成改组):

END
激活用户

在Windows启动程序组中,运行如下程序(C:\Program Files\ICW\bin\ copsshcp.exe):

进入COPSSH Control Panel应用对话框,正常情况下服务应该为正在运行(图标为绿色,如为红色,则可尝试点选该按钮,启动该服务):

选择Users页面:

点选Add按钮,出现如下导航对话框:

选择Forward按钮,出现如下页面,选择欲激活的用户对应的域名及用户名:

选择Forward按钮,进入如下页面,选择Linux shell and Sftp,所有选项选中:

选择Forward按钮,进入确认页面,选择Apply:

回到如下页面,选择Apply后,关闭。

4、CentOS系统怎样搭建Git版本控制服务器

yum安装Git服务器

代码如下:

[root@git ~]# cd src/
[root@git src]# wget http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[root@git src]# rpm -ivh epel-release-5-4.noarch.rpm
Preparing... ########################################### [100%]
package epel-release-5-4.noarch is already installed
[root@git ~]# yum list
[root@git ~]# yum install -y git

创建一个git用户,用来运行git服务

代码如下:

[root@git ~]# adser git

创建客户端登录证书,注,收集所有需要登录的用户的公钥,就是他们自己生成的id_rsa.pub文件,把所有公钥复制到/home/git/.ssh/authorized_keys文件里,一行一个。嘿嘿!

1).客户端生成id_rsa.pub文件的命令


代码如下:

$ ssh-keygen -t rsa
$ cat .ssh/id_rsa.pub

ssh-rsa ++N3wEAQRYDmcYo1wmnm/4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+== leo@LEO-PC

注,一路回车即可,将生成的id_rsa.pub,复制给管理员,帮你在服务器上增加一下,下次你用git时就不需要输入用户名和密码了。

2).查看服务器上authorized_keys文件

代码如下:

[root@git ~]# cat /home/git/.ssh/authorized_keys
ssh-rsa wBVd++YmJFhqwkITNGccrO5sycROs9+Fbjgd6oBSzNuaBtCIbwNNsEyM/henTl2euI3XsnJQ/ITr6c/q0P3WoGl4E2QFQ2kZqs++/+kJzJSKUTKDVSwY3/+Q== root@CHENMINGQIAN
ssh-rsa +PSK9PSg+bwiJ2iQRa39rXck35r+//RiCiYzd3RT/+S/LD3vx2MN+FNOHwvqcE+/5yEqSgAkioa8SVMOsikYJG//RZ54Q== Administrator@WIN2003X323
ssh-rsa ++N3wEAQRYDmcYo1wmnm/4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+== leo@LEO-PC

说明:我这里有三个用户登录服务器,所以我这里就有三个ssh-rsa,大家可以看一下。

初始化Git仓库
注,先选定一个目录作为Git仓库,这里是/data/git/project.git。

代码如下:

[root@git ~]# cd /data/git/
[root@git git]# git init --bare project.git
[root@git project.git]# ls
branches config description HEAD hooks index info objects refs

执行以上命令 Git命令,会创建一个裸仓库,裸仓库没有工作区,因为服务器上的Git仓库纯粹是为了共享,所以不让用户直接登录到服务器上去改工作区,并且服务器上的Git仓库通常都以.git结尾。然后,把owner改为git:

代码如下:

[root@git git]# chown -R git.git project.git
[root@git git]# ls -l

总计 4

代码如下:

drwxr-xr-x 7 git git 4096 05-09 13:50 project.git

禁用shell登录
注,出于安全考虑,第二步创建的git用户不允许登录shell,这可以通过编辑/etc/passwd文件完成。找到类似下面的一行:

代码如下:

[root@git ~]# cat /etc/passwd | grep git
git:x:1001:1001:git version control:/home/git:/bin/bash

改为:

代码如下:

[root@git ~]# vim /etc/passwd
git:x:1001:1001:git version control:/home/git:/usr/bin/git-shell

这样,git用户可以正常通过ssh使用git,但无法登录shell,因为我们为git用户指定的git-shell每次一登录就自动退出。

克隆远程仓库
注,现在可以通过git clone命令克隆远程仓库了,在各自的电脑上运行:
注,$ git clone [email protected]:/data/git/project.git,其中git用户名,git.jjhh.com服务器,/data/git/prgject.git是仓库路径。好了,到这里服务器的搭建到这里就完成了,下面我们来安装一下客户端。

创建SSH Key
首先在用户主目录下,看看有没有.ssh目录,如果有,再看看这个目录下有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步。如果没有,打开Shell(Windows下打开Git Bash),创建SSH Key:

代码如下:

$ ssh-keygen -t rsa -C "[email protected]

你需要把邮件地址换成你自己的邮件地址,然后一路回车,使用默认值即可,由于这个Key也不是用于军事目的,所以也无需设置密码。
如果一切顺利的话,可以在用户主目录里找到.ssh目录,里面有id_rsa和id_rsa.pub两个文件,这两个就是SSH Key的秘钥对,id_rsa是私钥,不能泄露出去,id_rsa.pub是公钥,可以放心地告诉任何人。

Git服务器打开RSA认证
然后就可以去Git服务器上添加你的公钥用来验证你的信息了。在Git服务器上首先需要将/etc/ssh/sshd_config中将RSA认证打开,即:
1.RSAAuthentication yes     
2.PubkeyAuthentication yes     
3.AuthorizedKeysFile.ssh/authorized_keys
这里我们可以看到公钥存放在.ssh/authorized_keys文件中。所以我们在/home/git下创建.ssh目录,然后创建authorized_keys文件,并将刚生成的公钥导入进去。
然后再次clone的时候,或者是之后push的时候,就不需要再输入密码了:

代码如下:

Zhu@XXX/E/testgit/8.34
$ git clone [email protected]:/data/git/learngit.git
Cloning into 'learngit'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

5、如何在centos上搭建git服务器

Git没有客户端服务器端的概念,但是要共享Git仓库,就需要用到SSH协议(FTP , HTTPS , SFTP等协议也能实现Git共享,此文档不讨论),但是SSH有客户端服务器端,所以在windows下的开发要把自己的Git仓库共享出去的话,就必 须做SSH服务器。
一、安装GIT
Windows下使用msysgit,
本文使用Git-1.7.8-preview20111206.exe 安装要点步骤
安装完成后,可以使用Git bash在命令行模式下操作git

二、安装CopSSH

安装CopSSH之前先确保防火墙开启了SSH端口,这个虽然不影响CopSSH的安装,但是影响SSH访问,所以写在前面。
CopSSH是windows下的SSH服务器软件,下载地址baidu之,本文使用的是Copssh_4.1.0_Installer.exe,
安装完成后,到控制面板中新建一个管理员账户root,用这个账户来共享SSH。然后你在账户管理中会看到之前的SvcCOPSSH账户。
将root用户添加到CopSSH用户中,为简单操作,允许使用密码认证方式
若是不允许密码认证,则需要使用公钥密钥方式认证,
三、CopSSH中使用GIT

现在已经安装GIT和CopSSH,接下来需要做的就是让CopSSH可以使用GIT的命令,这样不仅能够远程SSH管理GIT服务器,而且可以将GIT仓库通过SSH共享。具体的操作方法是将GIT的某些命令程序和动态链接库复制到CopSSH安装目录下即可。

l 将$ Git\libexec\git-core目录下的git.exe , git-receive-pack.exe , git-upload-archive.exe , git-upload-pack.exe复制到$ICW\bin目录下

l 将$Git\bin目录下的libiconv-2.dll复制到$ICW\bin目录下

重启CopSSH即可

6、linux怎么搭建git服务器

GitHub就是一个免费托管开源代码的远程仓库。但是对于某些视源代码如生命的商业公司来说,既不想公开源代码,又舍不得给GitHub交保护费,那就只能自己搭建一台Git服务器作为私有仓库使用。
搭建Git服务器需要准备一台运行Linux的机器,强烈推荐用Ubuntu或Debian,这样,通过几条简单的apt命令就可以完成安装。
假设你已经有sudo权限的用户账号,下面,正式开始安装。
第一步,安装git:
$ sudo apt-get install git

第二步,创建一个git用户,用来运行git服务:
$ sudo adser git

第三步,创建证书登录:
收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
第四步,初始化Git仓库:
先选定一个目录作为Git仓库,假定是/srv/sample.git,在/srv目录下输入命令:
$ sudo git init --bare sample.git

Git就会创建一个裸仓库,裸仓库没有工作区,因为服务器上的Git仓库纯粹是为了共享,所以不让用户直接登录到服务器上去改工作区,并且服务器上的Git仓库通常都以.git结尾。然后,把owner改为git:
$ sudo chown -R git:git sample.git

第五步,禁用shell登录:
出于安全考虑,第二步创建的git用户不允许登录shell,这可以通过编辑/etc/passwd文件完成。找到类似下面的一行:
git:x:1001:1001:,,,:/home/git:/bin/bash

改为:
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

这样,git用户可以正常通过ssh使用git,但无法登录shell,因为我们为git用户指定的git-shell每次一登录就自动退出。
第六步,克隆远程仓库:
现在,可以通过git clone命令克隆远程仓库了,在各自的电脑上运行:
$ git clone git@server:/srv/sample.git
Cloning into 'sample'...
warning: You appear to have cloned an empty repository.

剩下的推送就简单了。

7、git 服务器的使用? 我自己在centos 服务器上搭了仓库

1. lvm 2. raid 3. distribute filesystem(glusterfs\sector\......) 4 (我不知道了) 前面的三选一,做完之后,两块盘当一块用,之后就是建个基本的服务器的事了。

8、如何搭建linux git服务器

首先我们分别在Git服务器和客户机中安装Git服务程序(刚刚实验安装过就不用安装了):
[root@linuxprobe ~]# yum install git
Loaded plugins: langpacks, proct-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Package git-1.8.3.1-4.el7.x86_64 already installed and latest version
Nothing to do

然后创建Git版本仓库,一般规范的方式要以.git为后缀:
[root@linuxprobe ~]# mkdir linuxprobe.git

修改Git版本仓库的所有者与所有组:
[root@linuxprobe ~]# chown -Rf git:git linuxprobe.git/

初始化Git版本仓库:
[root@linuxprobe ~]# cd linuxprobe.git/
[root@linuxprobe linuxprobe.git]# git --bare init
Initialized empty Git repository in /root/linuxprobe.git/

其实此时你的Git服务器就已经部署好了,但用户还不能向你推送数据,也不能克隆你的Git版本仓库,因为我们要在服务器上开放至少一种支持Git的协议,比如HTTP/HTTPS/SSH等,现在用的最多的就是HTTPS和SSH,我们切换至Git客户机来生成SSH密钥:
[root@linuxprobe ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
65:4a:53:0d:4f:ee:49:4f:94:24:82:16:7a:dd:1f:28 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| .o+oo.o. |
| .oo *.+. |
| ..+ E * o |
| o = + = . |
| S o o |
| |
| |
| |
| |
+-----------------+

将客户机的公钥传递给Git服务器:
[root@linuxprobe ~]# ssh-copy-id 192.168.10.10
[email protected]'s password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.10.10'"
and check to make sure that only the key(s) you wanted were added.

此时就已经可以从Git服务器中克隆版本仓库了(此时目录内没有文件是正常的):
[root@linuxprobe ~]# git clone [email protected]:/root/linuxprobe.git
Cloning into 'linuxprobe'...
warning: You appear to have cloned an empty repository.
[root@linuxprobe ~]# cd linuxprobe
[root@linuxprobe linuxprobe]#

初始化下Git工作环境:
[root@linuxprobe ~]# git config --global user.name "Liu Chuan"
[root@linuxprobe ~]# git config --global user.email "[email protected]"
[root@linuxprobe ~]# git config --global core.editor vim

向Git版本仓库中提交一个新文件:
[root@linuxprobe linuxprobe]# echo "I successfully cloned the Git repository" > readme.txt
[root@linuxprobe linuxprobe]# git add readme.txt
[root@linuxprobe linuxprobe]# git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached ..." to unstage)
#
# new file: readme.txt
#
[root@linuxprobe linuxprobe]# git commit -m "Clone the Git repository"
[master (root-commit) c3961c9] Clone the Git repository
Committer: root
1 file changed, 1 insertion(+)
create mode 100644 readme.txt
[root@linuxprobe linuxprobe]# git status
# On branch master
nothing to commit, working directory clean

但是这次的操作还是只将文件提交到了本地的Git版本仓库,并没有推送到远程Git服务器,所以我们来定义下远程的Git服务器吧:
[root@linuxprobe linuxprobe]# git remote add server [email protected]:/root/linuxprobe.git

将文件提交到远程Git服务器吧:
[root@linuxprobe linuxprobe]# git push -u server master
Counting objects: 3, done.
Writing objects: 100% (3/3), 261 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To [email protected]:/root/linuxprobe.git
* [new branch] master -> master
Branch master set up to track remote branch master from server.

为了验证真的是推送到了远程的Git服务,你可以换个目录再克隆一份版本仓库(虽然在工作中毫无意义):
[root@linuxprobe linuxprobe]# cd ../Desktop
[root@linuxprobe Desktop]# git clone [email protected]:/root/linuxprobe.git
Cloning into 'linuxprobe'...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
[root@linuxprobe Desktop]# cd linuxprobe/
[root@linuxprobe linuxprobe]# cat readme.txt
I successfully cloned the Git repository

这篇是详细介绍Git的,中间有一部分是怎么去搭建,你可以看下

9、如何在centos上 安装git服务器

1.首先下载git源码
2.xz文件解压
xz -d git-2014-08-20.tar.xz
tar -xvf git-2014-08-20.tar
3.安装git
cd git-2014-08-20/
autoconf
./configure --prefix=/usr/local/git/
make
make install
如果make的时候报错:/bin/sh: msgfmt: command not found

则需要:
yum install gettext-devel

4.将git加到环境变量中
vim /etc/profile
export GIT_HOME=/usr/local/git/
export PATH=$PATH:$GIT_HOME/bin
这样就可以直接运行git命令了。

与centos7搭建git服务器相关的知识