1. 安装git
apt-get install git2. 添加git用户
useradd git -m3. 禁用git用户的ssh登录
修改/etc/passwd文件:
git:x:1001:1001:,,,:/home/git:/bin/sh
改为:
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell4. 新建repo
mkdir /home/git/repos
cd /home/git/repos
git init --bare sample.git
// 修改权限
chown -R git:git ../repos5.添加公钥
把本机电脑的id_rsa.pub添加到/home/git/.ssh/authorized_keys即可,多台电脑则一行一个。
6.现在可以正常使用git了
git clone git@server_ip:/home/git/repos/sample.git
git commit
git push
...
评论