1. 下载插件
yum remove git
yum install gcc
yum install gcc-c++
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc perl-ExtUtils-MakeMaker
wget -P ./ https://www.kernel.org/pub/software/scm/git/git-2.20.1.tar.gz
2. 解压并下载
tar zxvf git-2.20.1.tar.gz
cd git-2.20.1/
./configure --prefix=/usr/local/git && make install
echo 'export PATH=$PATH:/usr/local/git/bin' > /etc/profile.d/git.sh
source /etc/bashrc
3. 创建用户组与创建用户
groupadd git
useradd -g git git_shell
passwd git_shell
git123456
4. 初始化git仓库并给予权限
mkdir /var/gitwarehouse
cd /var/gitwarehouse
git init --bare testInfo.git
chown -R git_shell:git testInfo.git
5. 克隆仓库
git clone git_shell@192.168.190:/var/gitwarehouse/testInfo.git
6. 创建其他用户
useradd -g git git_user_two
passwd git_user_two
git_two_123456
#查看组成员
//找出用户组的 git:x:1001 得出gid=1001
cat /etc/group
//列出git组的所有成员
awk -F":" '{print $1"\t"$4}' /etc/passwd |grep '1001'
7. 设置 .ssh
cd /home/git_shell
mkdir ./.ssh
chown -R git_shell:git .ssh/
touch .ssh/authorized_keys
chown -R git_shell:git .ssh/authorized_keys
#修改 /etc/ssh/sshd_config
vi /etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
#修改 /etc/ssh/ssh_config
vi /etc/ssh/ssh_config
RSAAuthentication yes
service sshd restart
复制客户端公钥到 authorized_keys
8. 客户端生成ssh教程
网友评论