如何搭建你的git server
在云VPS上面搭建一台git server的过程:git是分布式的代码仓库,其实不是区分git-server和git-client的。只不过,我们开发小组要共用的仓库,就叫server。git是依赖于ssh的,VPS缺省必备SSH,否则无法远程管理。我们要做哪些工作呢?创建git repo,添加各member的ssh-key.pub。$ adduser git$ passwd
·
在云VPS上面搭建一台git server的过程:
git是分布式的代码仓库,其实不是区分git-server和git-client的。只不过,我们开发小组要共用的仓库,就叫server。
git是依赖于ssh的,VPS缺省必备SSH,否则无法远程管理。
我们要做哪些工作呢?创建git repo,添加各member的ssh-key.pub。
$ adduser git
$ passwd git
$ visudo //root用户下执行,添加git用户进去。
$ su git //切换到git帐户
你可能发现问题:没有.ssh目录呢?
[root@localhost ~]# su git
[git@localhost root]$ ssh-keygen -t rsa //创建产生ssh key,也就有.ssh目录了!
Generating public/private rsa key pair.
Enter file in which to save the key (/home/git/.ssh/id_rsa):
Created directory '/home/git/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/git/.ssh/id_rsa.
Your public key has been saved in /home/git/.ssh/id_rsa.pub.
The key fingerprint is:
a2:dd:5e:d6:38:9d:c5:85:34:85:d0:10:d8:ce:cb:4a git@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
| o+=oo.|
| . ..oo |
| o . .|
| o. . |
| . S . .o |
| o o E+oo |
| . . ..=.+ |
| . o.. |
| . |
+-----------------+
[git@localhost root]$
这样就有了。
$ sudo vi /home/git/.ssh/authorized_keys
将client pc( team member)的~/.ssh/id_rsa.pub里面的key添加进来!保存。
然后就是创建仓库repo了
$ mkdir /home/git/repo; cd /home/git/repo
$ git init --bare project.git
Initialized empty Git repository in /home/git/project.git/
$ sudo chown -R git:git /home/git/repo
然后进入client pc中,git-bash下面执行:
Administrator@USER-20141115MU MINGW64 /f/gitserver/project
$ git clone git@110.185.210.89:/home/git/repo/project.git
Cloning into 'project'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done. //成功创建!!!
Administrator@USER-20141115MU MINGW64 /f/gitserver/project
$
我打算把git server创建到docker image中,随之而来的问题就是改了ssh port后git要修改.ssh/config
git是分布式的代码仓库,其实不是区分git-server和git-client的。只不过,我们开发小组要共用的仓库,就叫server。
git是依赖于ssh的,VPS缺省必备SSH,否则无法远程管理。
我们要做哪些工作呢?创建git repo,添加各member的ssh-key.pub。
$ adduser git
$ passwd git
$ visudo //root用户下执行,添加git用户进去。
$ su git //切换到git帐户
你可能发现问题:没有.ssh目录呢?
[root@localhost ~]# su git
[git@localhost root]$ ssh-keygen -t rsa //创建产生ssh key,也就有.ssh目录了!
Generating public/private rsa key pair.
Enter file in which to save the key (/home/git/.ssh/id_rsa):
Created directory '/home/git/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/git/.ssh/id_rsa.
Your public key has been saved in /home/git/.ssh/id_rsa.pub.
The key fingerprint is:
a2:dd:5e:d6:38:9d:c5:85:34:85:d0:10:d8:ce:cb:4a git@localhost.localdomain
The key's randomart image is:
+--[ RSA 2048]----+
| o+=oo.|
| . ..oo |
| o . .|
| o. . |
| . S . .o |
| o o E+oo |
| . . ..=.+ |
| . o.. |
| . |
+-----------------+
[git@localhost root]$
这样就有了。
$ sudo vi /home/git/.ssh/authorized_keys
将client pc( team member)的~/.ssh/id_rsa.pub里面的key添加进来!保存。
然后就是创建仓库repo了
$ mkdir /home/git/repo; cd /home/git/repo
$ git init --bare project.git
Initialized empty Git repository in /home/git/project.git/
$ sudo chown -R git:git /home/git/repo
然后进入client pc中,git-bash下面执行:
Administrator@USER-20141115MU MINGW64 /f/gitserver/project
$ git clone git@110.185.210.89:/home/git/repo/project.git
Cloning into 'project'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done. //成功创建!!!
Administrator@USER-20141115MU MINGW64 /f/gitserver/project
$
我打算把git server创建到docker image中,随之而来的问题就是改了ssh port后git要修改.ssh/config
更多推荐
已为社区贡献10条内容
所有评论(0)