Q:rsync作爲服務器時,加密傳輸無法連通。
[root@client ~]# rsync -av [email protected]::share /root/test
Password:
@ERROR: auth failed on module share
rsync error: error starting client-server protocol (code 5) at main.c(1503) [receiver=3.0.6]
[root@client ~]#
A:
1.排查配置文件
[root@server ~]# vim /etc/rsyncd.secrets
1 root:123456
[root@server ~]# vim /etc/rsyncd.conf
1 [share]
2 path=/root/dir2
3 read only=false
4 uid=root
5 gid=root
6 # motd file=/etc/rsyncd.welcome
7 ##the file of welcome
8 auth users = root
9 secrets file= /etc/rsyncd.secrets
10 comment=xxx
2.檢查iptables與selinux
[root@server ~]# service iptables stop
[root@server ~]# service iptables start
iptables: Applying firewall rules: [ OK ]
[root@server ~]# service iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@server ~]# getenforce
Disabled
3.監測端口873 監聽正常
[root@server ~]# netstat -nptl|grep 873
tcp 0 0 :::873 :::* LISTEN 7885/xinetd
4.將/etc/rsyncd.secrets 權限設爲600
[root@server ~]# chmod 600 /etc/rsyncd.secrets
[root@server ~]# ll /etc/rsyncd.secrets
-rw------- 1 root root 13 Apr 19 17:37 /etc/rsyncd.secrets
[root@server ~]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
[root@server ~]#
可以成功傳送文件。
注:
1. 要保證運行rsync的用戶權限必須與rsyncd.secrets權限保持一致。
2. 一旦啓用密碼登錄,則只有auth user設定好的用戶可以通過密碼同步,其他用戶全部拒絕!