远程连接错误及解决
本次实现宿主机为opensuse tumbleweed,远程连接的机器为rhel6.0,且在同一LAN下,suse的ip
:192.168.3.109
在rhel6.0系统下/etc/services文件是记录网络服务名和它们对应使用的端口号及协议,不过这里不用设置
No route to host
[tom@ton ~]$cvs login
Logging in to :pserver:anonymous@192.168.3.109:2401/home/tom/cvs/test/tom-csv
CVS password:
cvs [login aborted]: connect to [192.168.3.109]:2401 failed: No route to host
[tom@ton ~]$telnet 192.168.3.109 2401 #测试发现2401口未开放
Trying 192.168.3.109...
telnet: connect to address 192.168.3.109: No route to host
开放2401端口
firewall-cmd --permanent --add-port=2401/tcp
firewall-cmd --reload
Connection refused
[tom@ton ~]$cvs login
Logging in to :pserver:tom@192.168.3.109:2401/home/tom/cvs
CVS password:
cvs [login aborted]: connect to [192.168.3.109]:2401 failed: Connection refused
添加xinetd脚本
/etc/xinetd.d/cvspserver文件,为连接到本机的2401端口的客户自动启动一个cvs会话,端口2401是标准的cvs服务监听端口。
# CVS pserver (remote acces to your CVS repositories)
# Please read the section on security and passwords in the CVS manual,
# before you enable this.
# default: off
service cvspserver
{
disable = no
socket_type = stream
protocol = tcp
port = 2401
wait = no
user = root
server = /usr/bin/cvs
server_args = -f --allow-root=/home/tom/cvs pserver
}
suse-tom:~ # vim /etc/xinetd.d/cvspserver
suse-tom:~ # service xinetd restart
可以看到xinetd对2401端口做了监听
suse-tom:/etc/xinetd.d # sudo lsof -i -n -P | grep xinetd
xinetd 13378 root 5u IPv6 57193 0t0 TCP *:2401 (LISTEN)
xinetd 13378 root 6u IPv6 57194 0t0 TCP *:13 (LISTEN)
或者netstat一下
[tom@suse-tom tom-csv]$sudo netstat -tnl |grep 2401
tcp6 0 0 :::2401 :::* LISTEN
no such repository
[tom@ton ~]$cvs login
Logging in to :pserver:anonymous@192.168.3.109:2401/home/tom/cvs/test/tom-csv
CVS password:
cvs [login aborted]: unrecognized auth response from 192.168.3.109: cvs [pserver aborted]: /home/tom/cvs/test/tom-csv: no such repository
原因:指定的仓库中与上面pserver xinetd配置中的–allow-root = 选项不相匹配
[tom@ton ~]$vim .bashrc
[tom@ton ~]$source .bashrc
即没有正确地设置环境变量CVSROOT
export CVSROOT=:pserver:tom@192.168.3.109:$HOME/cvs/test/tom-csv #更改为
export CVSROOT=:pserver:tom@192.168.3.109:$HOME/cvs
上述报错仍没有解决可以考虑一下远程连接的机器的问题,尝试关闭iptables在rhel6.0上
[tom@ton ~]$sudo service iptables stop
[sudo] password for tom:
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
成功连接
[tom@ton ~]$cvs login
Logging in to :pserver:tom@192.168.3.109:2401/home/tom/cvs
CVS password:
[tom@ton ~]$
参考https://danilodellaquila.com/en/blog/install-cvs-server-on-suse-11