linux下CVS服务器的安装: 环境说明 1)linux 版本:redhat-release-4ES-3; 2)cvs版本:cvs-1.11.17-8.RHEL4 一、CVS服务器的配置管理 1、查看你的操作系统上是否安装了CVS #> rpm -qa|grep cvs 如果没有安装你可以在Redhat 第2张光盘上找到,另外你也可以在网上下载到最新的rpm包。很容易找。 2、建立cvs用户组 #> groupadd cvs 3、建立cvs组的cvsroot用户和所属的目录 #> useradd -g cvs -d /cvsroot cvsroot 4、为cvsroot用户添加密码 #> passwd cvsroot 5、改变 /cvsroot/ 的目录属性 #> chmod 777 /cvsroot 6、改变用户登陆身份: #> su cvsroot 7、开始创建单个项目 #> cd /cvsroot #> mkdir project1 #>mkdir project2 8、开始建立仓库 #> cvs -d/cvsroot/project1 init #> cvs -d/cvsroot/project2 init #> chmod 775 ./project1/ ./project2/ 9、建立CVS服务启动文件,我们使用xinetd方式 注意:要严格拷贝下文,包括=号两边的空格也严格要求,否则出错。 #> [Crtl]+[d] 切换到root用户身份 #> cd /etc/xinetd.d #> vi cvspserver service cvspserver { disable = no flags = REUSE socket_type = stream wait = no user = root server = /usr/bin/cvs server_args = -f --allow-root=/cvsroot/project1 --allow-root=/cvsroot/project2 pserver log_on_failure += USERID } 10、加入cvs服务 #>vi /etc/services 在vi中用命令?cvs或者/cvs查看是否设置了cvspserver服务,若已经设置则不用下面的命令,否则在底端local处加上下面的命令 cvspserver 2401/tcp #pserver cvs service cvspserver 2401/udp #pserver cvs service 11、启动cvs服务 [root@linuxserver xinetd.d]# /etc/init.d/xinetd restart 停止 xinetd: [ 确定 ] 启动 xinetd: [ 确定 ] 12、检查cvspserver服务是否已经启动,若没有启动,请看第三部分问题解决办法 #> netstat -l |grep cvspserver 应该有如下结果,否则服务器配置错误: [root@linuxserver xinetd.d]# netstat -l |grep cvspserver tcp 0 0 *:cvspserver *:* LISTEN 二、CVS服务的用户管理 上面我们已经建立了project1和project2两个CVS仓库,下面我们分别给两个仓库建立cvs用户,这里的cvs用户和系统用户是不同的。 13、创建可以登陆cvs服务器的用户名和密码: 注意:目录/cvsroot/project1/CVSROOT/是第8步自动生成的,用大写CVSROOT #> su cvsroot #> vi /cvsroot/project1/CVSROOT/passwd trotter:*****:cvsroot mimi:*****:cvsroot #>vi /cvsroot/project2/CVSROOT/passwd trotter:*****:cvsroot gary:*****:cvsroot 说明:这两个文件的意思是有trotter,mimi,gary三个cvs用户,mimi拥有project1的使用权限,gary拥有project2的使用权限,trotter拥有project1和project2的使用权限。登陆后的权限是cvsroot权限。 14、第13步中*****为密码,由以下文件生成,该文件需严格拷贝过来 #> vi /cvsroot/passwd.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}"; 修改属性为可执行 #>chmod a+x /cvsroot/passwd.pl 15、如果你想生成一个密码是"test",则 #> /cvsroot/passwd.pl "test" 回车即可得到加密密码,如JkbT.RA9dvvXE 用其替换passwd文件中的***** 注意:1) /cvsroot/passwd.pl后的参数必须用半角双引号括起来 2)同一原文但是每次生成的加密字符串不同的 16、测试 cvs现在已经全部安装完成了,如果你想让一个用户拥有project1的权限,你就在/cvsroot/project1/CVSROOT/passwd中给他加入一个用户;如果你想让一个用户同时具有project1和project2的权限,你就给/cvsroot/project1/CVSROOT/passwd和/cvsroot/project2/CVSROOT/passwd里给他加一个用户名和密码相同的用户即可。最后,我们测试一下: #> cvs -d :pserver:trotter@192.168.1.200:/cvsroot/project1 login 敲入命令回车后提示输入trotter的密码,你按照自己设置的密码输入,如果没有什么错误信息出现就是成功了(机器IP地址是192.168.1.200,端口号不用加,使用默认的2401) 三、可能出现的问题以及解决办法 17、若提示错误cvs [login aborted]: unrecognized auth response from 则在启动cvspserver脚本里面加上这条/usr/sbin/setenforce 0 命令 #> [Crtl]+[d] 切换到root用户身份 #> cd /etc/xinetd.d #> vi cvspserver /usr/sbin/setenforce 0 18、若仍然无法连接服务器,需要进一步调试,则先查看cvs错误日志,请查找 inetd 的日志文件(/var/log/messages ),日志在第四部分附。通过日志可看到错误的原因,根据日志来查错,排错,比较快捷。 [root@linuxserver xinetd.d]# more /var/log/messages |grep cvs 19、用telnet方法调试,很好用的调试工具,详见参考三 [root@linuxserver ~]# telnet localhost 2401 连接以后,发任意一个文本 (例如 "foo" 并回车)。如果 cvs 工作正常,将回显 cvs [pserver aborted]: bad auth protocol start: foo 如果是看到: Usage: cvs [cvs-options] command [command-options-and-arguments] 则检查/etc/xinetd.d/cvspserver文件,比如cvs 和pserver命令行,确保书写正确、完整。 20、若出现server cvs: login failure (for /cvsroot/project1),说明用户配置不正确,请检查分配的帐号是否正确。 四、参考 1)http://dev.csdn.net/article/67/67183.shtm 2)http://blog.chinaunix.net/u/4631/showart_215464.html 3)http://man.chinaunix.net/develop/cvsdoc_zh/Error-messages.html 4) http://cvs.nongnu.org/ 五、操作的错误以及日志: 1)操作第16步后 [cvsroot@linuxserver CVSROOT]$ cvs -d :pserver:test@172.16.0.4:/cvsroot/project1 login Logging in to :pserver:test@172.16.0.4:2401/cvsroot/project1 CVS password: cvs [login aborted]: unrecognized auth response from 172.16.0.4: Usage: cvs [cvs-options] command [command-options-and-arguments] 2)操作第17步后 cvs [login aborted]: connect to 172.16.0.4(172.16.0.4):2401 failed: Connection refused 3)查系统错误日志 [root@linuxserver xinetd.d]# more /var/log/messages |grep cvs May 27 08:45:58 linuxserver passwd(pam_unix)[16071]: password changed for cvsroot May 27 08:49:23 linuxserver su(pam_unix)[16171]: session opened for user cvsroot by root(uid=0) May 27 09:00:59 linuxserver su(pam_unix)[16171]: session closed for user cvsroot May 27 09:10:34 linuxserver su(pam_unix)[17099]: session opened for user cvsroot by root(uid=0) May 27 10:27:32 linuxserver su(pam_unix)[21207]: session opened for user cvsroot by root(uid=0) May 27 11:20:07 linuxserver xinetd[21030]: readjusting service cvspserver May 27 13:48:34 linuxserver su(pam_unix)[21207]: session closed for user cvsroot May 27 13:48:34 linuxserver su(pam_unix)[17099]: session closed for user cvsroot May 27 14:37:51 linuxserver xinetd[27628]: Bad operator for attribute: /usr/sbin/setenforce [file=/etc/xinetd.d/cvspserver] [line=10] May 27 15:00:55 linuxserver xinetd[28647]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:03:48 linuxserver xinetd[28732]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:07:06 linuxserver xinetd[28883]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:08:46 linuxserver xinetd[29050]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:11:50 linuxserver xinetd[29248]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:13:28 linuxserver xinetd[29336]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:15:39 linuxserver xinetd[29467]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:17:37 linuxserver xinetd[29643]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:21:13 linuxserver xinetd[2047]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=8] May 27 15:23:46 linuxserver su(pam_unix)[3249]: session opened for user cvsroot by root(uid=0) May 27 15:24:49 linuxserver su(pam_unix)[3249]: session closed for user cvsroot May 27 16:50:35 linuxserver xinetd[5409]: missing } in last service entry [file=/etc/xinetd.d/cvspserver] [line=20] May 27 17:10:41 linuxserver xinetd[6480]: bad service attribute: log [file=/etc/xinetd.d/cvspserver] [line=10] May 27 17:13:16 linuxserver xinetd[6520]: bad service attribute: log [file=/etc/xinetd.d/cvspserver] [line=10] May 28 09:51:28 linuxserver xinetd[23551]: bad service attribute: log [file=/etc/xinetd.d/cvspserver] [line=10] May 28 09:59:49 linuxserver xinetd[24082]: bad service attribute: log [file=/etc/xinetd.d/cvspserver] [line=10] May 28 10:29:43 linuxserver xinetd[25011]: Attribute server needs a space before operator [file=/etc/xinetd.d/cvspserver] [line=16] May 28 10:35:40 linuxserver cvs: login failure (for /cvsroot/project1) May 28 10:36:42 linuxserver cvs: login failure (for /cvsroot/project1) May 28 10:40:18 linuxserver cvs: login failure (for /cvsroot/project1) May 28 10:40:25 linuxserver cvs: login failure (for /cvsroot/project1) May 28 10:40:45 linuxserver cvs: login failure (for /cvsroot/project1) 4)[root@linuxserver ~]# cvs -d :pserver:tyut@172.16.0.4:/cvsroot/project1 login Logging in to :pserver:tyut@172.16.0.4:2401/cvsroot/project1 CVS password: cvs [login aborted]: connect to 172.16.0.4(172.16.0.4):2401 failed: Connection refused 5)调试 [root@linuxserver ~]# telnet localhost 2401 Trying 127.0.0.1... Connected to localhost.localdomain (127.0.0.1). Escape character is '^]'. Usage: cvs [cvs-options] command [command-options-and-arguments] where cvs-options are -q, -n, etc. (specify --help-options for a list of options) where command is add, admin, etc. (specify --help-commands for a list of commands or --help-synonyms for a list of command synonyms) where command-options-and-arguments depend on the specific command (specify -H followed by a command name for command-specific help) Specify --help to receive this message The Concurrent Versions System (CVS) is a tool for version control. For CVS updates and additional information, see the CVS home page at http://www.cvshome.org/ or Pascal Molli's CVS site at http://www.loria.fr/~molli/cvs-index.html /cvsroot/cvs.run: line 3: --allow-root: command not found /cvsroot/cvs.run: line 4: --allow-root: command not found /cvsroot/cvs.run: line 5: pserver: command not found Connection closed by foreign host. 6)查看cvs 版本 [root@linuxserver ~]# cvs -v Concurrent Versions System (CVS) 1.11.17 (client/server)