看了不少CVS伺服器的安裝說明,自己也著手開始進行CVS伺服器的安裝,現將安裝及配置記錄如下:
OS環境:RedHat Linux 9
CVS:cvs-1.12.9.tar.gz (:http://www.cvshome.org)
一、源碼包安裝
一般來說RedHat Linux 9預設是安裝有cvs的,我們可以通過以下命令查看
[root@VLinux root]# rpm -qa | grep cvs
rpm -e cvs-1.11.2-10
如果出現上面一行的顯示則說明已經安裝有CVS,我們可以通過以下命令卸載
[root@VLinux root]# rpm -e cvs-1.11.2-10
好了,下面開始正式安裝
[root@VLinux src]# tar -zxvf cvs-1.12.9.tar.gz
[root@VLinux src]# cd cvs-1.12.9
[root@VLinux cvs-1.12.9]# ./configure --prefix=/usr/local/cvs --exec-prefix=/usr --disable-server-flow-control
[root@VLinux cvs-1.12.9]# make
[root@VLinux cvs-1.12.9]# make install
二、佈建服務
加入cvs服務
[root@VLinux root]#vi /etc/services
cvspserver 2401/tcp #pserver cvs service
cvspserver 2401/udp #pserver cvs service
一般redhat9預設就有cvs服務,所以不用加
在Linux上CVS服務可以通過inetd、xinetd或tcpwrapper等來啟動,其中inetd由於安全理由在許多場合已經被xinetd所取代了。這裡我們使用xinetd來啟動CVS服務。
在/etc/xinetd.d目錄下為CVS服務建立一個設定檔,比如:/etc/xinetd.d/cvspserver,編輯/etc/xinetd.d/cvspserver,輸入如下內容:
service cvspserver
{
disable = no
socket_type = stream
wait = no
user = root
env = HOME=
server = /usr/bin/cvs
server_args = -f --allow-root=/home/cvsroot pserver
}
註:
1)pserver表示是口令認證的訪問方式,這是最常用的方式,其他還有gserver,kserver,ext,如果想要更高的安全性可以使用ssh來加密口令和資料流,
不過這裡為了使用者使用的方便,仍然選的是pserver
2)--allow-root是指定Repository的目錄,可以建立多個Repository
然後重新啟動xinetd:
[root@VLinux root]# /etc/rc.d/init.d/xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
重新啟動xinetd服務後,CVS服務也開始工作了。
三、初始化CVS伺服器
首先要建立一個名為cvs的組和一個名為cvsroot的使用者,以後要訪問CVS服務的使用者加入cvs這個組:
[root@VLinux root]# groupadd cvs
[root@VLinux root]# useradd -g cvs -G cvs -d /home/cvsroot -s /sbin/nologin cvsroot
[root@VLinux root]# chmod 755 /home/cvsroot
接下來進行初始化:
[root@VLinux root]# cvs -d /home/cvsroot init
這樣在/home/cvsroot目錄中就產生了CVSROOT目錄,其中存放了一些設定檔,如config等,然後設定許可權:
[root@VLinux root]# chown -R cvsroot.cvs /home/cvsroot
[root@VLinux root]# chmod -R ug+rwx /home/cvsroot
[root@VLinux root]# chmod 644 /home/cvsroot/CVSROOT/config
下面開始建立CVS使用者
建立密碼組建檔案passwdgen.pl,並設定為可執行
[root@VLinux root]# vi /home/cvsroot/passwdgen.pl
#!/usr/bin/perl
srand (time());
my $randletter = "(int (rand (26)) + (int (rand (1) + .5) % 2 ? 65 : 97))";
my $salt = sprintf ("%c%c", eval $randletter, eval $randletter);
my $plaintext = shift; my $crypttext = crypt ($plaintext, $salt);
print "${crypttext}/n";
[root@VLinux root]# chmod +x /home/cvsroot/passwdgen.pl
將設要產生的密碼為"123456",則使用如下命令
[root@VLinux root]# /home/cvsroot/passwdgen.pl "123456"
MbQ2iaN85u3mM
結果"MbQ2iaN85u3mM"即為所要的密碼
接著分別建立設定檔:passwd,writers和readers
[root@VLinux root]# vi /home/cvsroot/CVSROOT/passwd
jasonseaver:MbQ2iaN85u3mM:cvsroot
jack:MbQ2iaN85u3mM:cvsroot
[root@VLinux root]# vi /home/cvsroot/CVSROOT/writers
jasonseaver
[root@VLinux root]# vi /home/cvsroot/CVSROOT/readers
jack
這樣就分別建立了可以讀寫CVS Repository的帳號jasonseaver (密碼123456)和唯讀帳號jack(密碼123456)
最後,測試一下
[root@VLinux root]# cvs -d :pserver:jasonseaver@192.168.0.5:/home/cvsroot login
輸入密碼後,沒有收到任何訊息,即表示成功
參考文章
CVS伺服器快速指南 http://oldsite.linuxaid.com.cn/solution/showsol.jsp?i=394
架設安全的CVS伺服器 http://www.yesky.com/SoftChannel/72341285217763328/20040220/1770105_2.shtml