柚子快報邀請碼778899分享:Git私服搭建
柚子快報邀請碼778899分享:Git私服搭建
1、安裝?openssh服務(wù)器?
sudo?apt-get?install?openssh-server?openssh-client
2、創(chuàng)建個人公鑰和私鑰?
在默認(rèn)用戶的主目錄路徑下,運(yùn)行以下命令,按照提示創(chuàng)建公鑰和私鑰?
ssh-keygen?-t?rsa
默認(rèn)生成2048位,如果需要提高安全級別,也可以通過下面的命令創(chuàng)建公鑰和私鑰?
ssh-keygen?-t?rsa?-b?4096
默認(rèn)情況下,公鑰和私鑰會保存在~/.ssh目錄下,如下所示:?
id_rsa??id_rsa.pub??known_hosts
3、安裝?git服務(wù)器?
sudo?apt-get?install?git-core
4、配置?git服務(wù)器?
創(chuàng)建git服務(wù)器管理用戶?
sudo?useradd?-m?git
sudo?passwd?git
創(chuàng)建git倉庫存儲目錄?
sudo?mkdir?/home/git/repositories
設(shè)置git倉庫權(quán)限?
sudo?chown?git:git?/home/git/repositories
sudo?chmod?755?/home/git/repositories
初始化全局設(shè)置?
git?config?--global?user.name?"myname"
git?config?--global?user.email?"myname@server"
5、安裝python的setup?tool?
sudo?apt-get?install?python-setuptools
6、獲取并安裝gitosis?
cd?/tmp
git?clone?GitHub - res0nat0r/gitosis: Manage git repositories, provide access to them over SSH, with tight access control and not needing shell accounts.
cd?gitosis
sudo?python?setup.py?install
7、配置gitosis?
cp?~/.ssh/id_rsa.pub?/tmp
sudo?-H?-u?git?gitosis-init?/tmp/id_rsa.pub
sudo?chmod?755?/home/git/repositories/gitosis-admin.git/hooks/post-update
8、管理gitosis配置?
cd?~
git?clone?git@hostname:用戶名/gitosis-admin.git
cd?gitosis-admin/
各個用戶按照前面提到的辦法生成各自的ssh公鑰文件后,服務(wù)器管理員把所有人的?ssh公鑰文件都拿來,拷貝到keydir目錄下。?
修改gitosis.conf文件,如下所示?
[gitosis]
[group?gitosis-admin]
writable?=?gitosis-admin
members?=?a@server1
[group?developers]
writable?=?helloworld
members?=?a@server1?b@server2
[group?test]?
readonly?=?helloworld
members?=?c@server3
這個配置文件表達(dá)了如下含義:gitosis-admin組成員有a,該組對gitosis-admin倉庫有讀寫權(quán)限;?developers組有a,b兩個成員,該組對helloworld倉庫有讀寫權(quán)限;?test組有c一個成員,對helloworld倉庫有只讀權(quán)限。?當(dāng)然目前這些配置文件的修改只是在你的本地,你必須推送到gitserver上才能真正生效。?加入新文件、提交并push到git服務(wù)器:?
git?add?.
git?commit?-am?"add?helloworld?project?and?users"
git?remote?add?origin?ssh://git@hostname/helloworld.git
git?push?origin?master
柚子快報邀請碼778899分享:Git私服搭建
好文鏈接
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場。
轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。