阿里云服务器搭建GIT服务器
环境:
- ubuntu16.04
- 阿里云服务器
二、服务器端配置
需要用root用户来执行以下命令
1. 添加用户
adduser git_xxx
cd /home/git_xxx
mkdir .ssh
2. 创建公钥文件
touch ./.ssh/authorized_keys
3. 添加用户公钥
vim ./.ssh/authorized_keys
4. 初始空的远程仓库
git init --bare sample_xxx.git
5. 文件修改拥有者
chown git_xxx:git_xxx sample_xxx.git
6. 禁止Git用户shell登录
vim /etc/passwd
//修改
git_db:x:1003:1003:,,,:/home/git_db:/bin/bash
//为
git_db:x:1003:1003:,,,:/home/git_db:/usr/bin/git-shell
二、远程仓库的使用方法
1.windows下在自己想要保存的文件夹下启动 git bash
输入命令
git clone git_xxx@120.78.209.0:/home/git_xxx/sample_xxx.git
如果显示以下,则表示成功,可以愉快的提交代码了。
warning: You appear to have cloned an empty repository.
Checking connectivity... done.