rsync @ERROR: auth failed on module backup 解决思路及附录rsync常见问题及解决办法

昨晚小版本上线,使用rsync往服务器上传文件时,client报如下异常:

@ERROR: auth failed on module backup

rsync error: error starting client-server protocol (code 5) at main.c(1503) [Receiver=3.0.6]

首先:检查server端和client端的用户名和密码确认都无误;

         服务器端检查这个/etc/rsync.pass密码文件,

        注:其它系统可能密码文件名字不一样可以在配置文件中搜索cat /etc/rsyncd.conf | grep -i secrets 来确认密码文件的名字

               不建议用ps -ef | greep -i rsync 因为如果rsync被设置成守护进程启动的,进程只显示为xinetd,所以用ps的命令搜不到

然后:检查了服务器端/etc/rsyncd.conf 配置文件未发现异常, 

再次:通过配置文件找到了log存放目录

$ cat /etc/rsyncd.conf | grep -i log

log file = /var/log/rsync.log

查看/var/log/rsync.log发现

2017/07/21 09:38:33 [31746] name lookup failed for xxx.xx.xxx.xx: Name or service not known
2017/07/21 09:38:33 [31746] connect from UNKNOWN (xxx.xx.xxx.xx)
2017/07/21 09:38:33 [31746] auth failed on module ci from unknown (xxx.xx.xxx.xx): missing secret for user "pesdfk"

 google搜索一下,发现其它网友解决方案,在server的/etc/hosts里加上IP和主机名的映射,我没有采用该建议。因为这个系统一直是我在维护,上周还有版本上线

运行都正常。

主要还是围绕客户端的@ERROR: auth failed on module backup在猜想,肯定是用户验证出了异常。

又google了一下,看到有网友提示,server端rsync.pass文件的格式user:passwrod , 修改成user:passwrod后在client端重新上传文件正常。

奇怪的是之前一直都正常,而且rsync.pass上次修改日期是2016年。

 

附录:rsync常见问题及解决办法 (转载自:http://kkkkkk.blog.51cto.com/468162/1194202)

问题一:

@ERROR: chroot failed
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]

原因:
服务器端的目录不存在或无权限,创建目录并修正权限可解决问题。

 

问题二:
@ERROR: auth failed on module tee
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]

原因:
服务器端该模块(tee)需要验证用户名密码,但客户端没有提供正确的用户名密码,认证失败。
提供正确的用户名密码解决此问题。

 

问题三:
@ERROR: Unknown module ‘tee_nonexists’
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]

原因:
服务器不存在指定模块。提供正确的模块名或在服务器端修改成你要的模块以解决问题。


问题四:
password file must not be other-accessible
continuing without password file
Password:
原因:
这是因为rsyncd.pwd rsyncd.secrets的权限不对,应该设置为600。如:chmod 600 rsyncd.pwd
问题五:
rsync: failed to connect to 218.107.243.2: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
原因:
对方没开机、防火墙阻挡、通过的网络上有防火墙阻挡,都有可能。关闭防火墙,其实就是把tcp udp的873端口打开。 

问题六:
rsync error: error starting client-server protocol (code 5) at main.c(1524) [Receiver=3.0.7]
原因:
/etc/rsyncd.conf配置文件内容有错误。请正确核对配置文件。
问题七:
rsync: chown "" failed: Invalid argument (22)
原因:
权限无法复制。去掉同步权限的参数即可。(这种情况多见于Linux向Windows的时候)


问题八:
@ERROR: daemon security issue -- contact admin
rsync error: error starting client-server protocol (code 5) at main.c(1530) [sender=3.0.6]
原因:
同步的目录里面有软连接文件,需要服务器端的/etc/rsyncd.conf打开use chroot = yes。掠过软连接文件。


问题九:
ERROR: module is read only
rsync error: syntax or usage error (code 1) at main.c(747) [receiver=2.6.8]
rsync: connection unexpectedly closed (4 bytes received so far) [sender]
rsync error: error in rsync protocol data stream (code 12) at io.c(600) [sender=3.0.6]
解决: 提示打开了read only,将配置文件 read only = no

问题十:
cat /var/log/rsyncd.log
2011/12/14 11:58:37 [22377] name lookup failed for XX.XX.XX.XX: Name or service not known
2011/12/14 11:58:37 [22377] connect from UNKNOWN (XX.XX.XX.XX)
2011/12/14 11:58:37 [22377] rsync to html/ from unknown (XX.XX.XX.XX)
解决:需要在服务端这台机上上的/etc/hosts里面添加客户端机的ip和机器名

问题十一: 

[root@Dell-R710 ~]# rsync -artuz -R --delete ./ 192.168.1.233::gex
rsync: failed to connect to 61.145.118.206: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(124) [sender=3.0.6]
解决:
一、查看防火墙
二、查看服务端是否开启守护进程
ps ax|grep rsync
rsync --daemon --config=/etc/rsyncd.conf

#####################################################################

 

问题1:
在client上遇到问题:
rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/
rsync: could not open password file "/etc/rsync.pas": No such file or directory (2)
Password: 
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]

遇到这个问题:client端没有设置/etc/rsync.pas这个文件,而在使用rsync命令的时候,加了这个参数--
password-file=/etc/rsync.pas

问题2:
rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/
@ERROR: auth failed on module backup
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
遇到这个问题:client端已经设置/etc/rsync.pas这个文件,里面也设置了密码111111,和服务器一致,但是
服务器段设置有错误,服务器端应该设置/etc/rsync.pas  ,里面内容root:111111 ,这里登陆名不可缺少

问题3:
rsync -auzv --progress --password-file=/etc/rsync.pas root@192.168.133.128::backup /home/
@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]

遇到这个问题,是因为服务器端的/home/backup  其中backup这个目录并没有设置,所以提示:chdir failed

问题4:
rsync: write failed on "/home/backup2010/wensong": No space left on device (28)
rsync error: error in file IO (code 11) at receiver.c(302) [receiver=3.0.7]
rsync: connection unexpectedly closed (2721 bytes received so far) [generator]
rsync error: error in rsync protocol data stream (code 12) at io.c(601) [generator=3.0.7]
磁盘空间不够,所以无法操作。
可以通过df /home/backup2010 来查看可用空间和已用空间

问题5:网络收集问题
1、权限问题
类似如下的提示:rsync: opendir "/kexue" (in dtsChannel) failed: Permission denied (13)注意查看同步的目录权限是否为755
2、time out
rsync: failed to connect to 203.100.192.66: Connection timed out (110)
rsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.5]
检查服务器的端口netstat –tunlp,远程telnet测试。


3、服务未启动
rsync: failed to connect to 10.10.10.170: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.5]
启动服务:rsync --daemon --config=/etc/rsyncd.conf


4、磁盘空间满
rsync: recv_generator: mkdir "/teacherclubBackup/rsync……" failed: No space left on device (28)
*** Skipping any contents from this failed directory ***


5、Ctrl+C或者大量文件
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544) [receiver=3.0.5]
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(544) [generator=3.0.5]


6、xnetid启动
rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(759) [receiver=3.0.5]
查看rsync日志
rsync: unable to open configuration file "/etc/rsyncd.conf": No such file or directory
xnetid查找的配置文件位置默认是/etc下,根据具体情况创建软链接。例如:
ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf
或者更改指定默认的配置文件路径,在/etc/xinetd.d/rsync配置文件中

 

转载于:https://www.cnblogs.com/reve-wang/p/7216582.html

<think>我们正在解决rsync备份时出现的身份验证失败问题,具体错误是密码不匹配(passwordmismatch)导致的,错误信息中还包含"errorstartingclient-serverprotocol(code5)sender3.1.2"。根据用户提供的引用[1],错误信息与之前类似,即认证失败(authfailedonmodule)和协议错误(code5)。引用[2]则提到了rsync在传输前会进行ssh登录认证,如果远端的.bashrc有输出会导致协议解析混乱。但是,当前问题明确是密码不匹配,所以我们主要关注密码验证部分,同时也要考虑是否因其他输出干扰了认证过程(比如模块配置错误导致的信息泄露)。结合之前我们给出的解决方案,这里再针对当前错误信息细化步骤:关键点:1.密码不匹配:服务器端密码文件(/etc/rsyncd.secrets)中的密码与客户端使用的密码不一致。2.协议错误(code5)通常由认证失败引起,但也要注意其他干扰(如.bashrc输出)可能导致协议解析问题。因此,我们分两部分解决:A.确保密码正确B.排除其他干扰(如.bashrc输出、SELinux、文件权限等)具体步骤:步骤1:验证服务器端密码文件格式和内容-服务器端密码文件路径:通常为/etc/rsyncd.secrets(具体路径参考rsyncd.conf中的`secretsfile`配置)-格式:每行一个用户,格式为`用户名:密码`(注意是冒号分隔)-检查命令:sudocat/etc/rsyncd.secrets-确保用户名与模块中`authusers`指定的用户名一致。步骤2:验证客户端密码文件-客户端密码文件:通常由`--password-file`参数指定,例如/etc/rsync.password-格式:只需要密码(不要包含用户名)-检查命令:cat/etc/rsync.password步骤3:检查模块配置-在服务器端的rsyncd.conf中,确保有对应的模块(如`[data]`)并且配置了`authusers`和`secretsfile`。-示例配置:[data]path=/path/to/dataauthusers=rsync_backupsecretsfile=/etc/rsyncd.secrets步骤4:文件权限-服务器端密码文件必须为root所有,权限为600:sudochownroot:root/etc/rsyncd.secretssudochmod600/etc/rsyncd.secrets-客户端密码文件同样需要安全权限(600)。步骤5:排除.bashrc等干扰-虽然引用[2]是关于ssh的,但rsync的daemon模式不使用ssh,不过如果客户端使用ssh模式则需注意。当前问题明确是daemon模式(使用模块名访问,如rsync_backup@10.0.0.41::data),因此不涉及ssh。但若用户混合使用,需注意。-如果确实使用了ssh模式,则检查远端服务器(即rsync服务器)上对应用户的.bashrc和.profile等文件,避免有任何输出(如echo、printf等)。步骤6:启用详细日志-在服务器端的rsyncd.conf中添加日志配置,以便查看详细错误:logfile=/var/log/rsyncd.logtransferlogging=yeslogformat=%t[%p]%o%a[%u]%f%l-重启rsyncd服务后,尝试连接并查看日志。步骤7:测试连接-在客户端使用详细输出模式测试:rsync-avv--password-file=/etc/rsync.password/tmp/testfilersync_backup@10.0.0.41::data-观察详细输出,寻找具体错误点。步骤8:考虑SELinux-如果服务器开启了SELinux,需要确保密码文件的安全上下文正确。可尝试:sudorestorecon-v/etc/rsyncd.secrets-或者临时禁用SELinux测试(生产环境慎用):sudosetenforce0步骤9:检查rsync版本兼容性-错误信息中显示sender版本为3.1.2,确保服务器端和客户端的rsync版本兼容。通常版本相差不大不会出现问题,但可尝试升级到相同版本。根据以上步骤,我们应能解决密码不匹配问题。如果问题依旧,请提供详细的日志信息。下面,我们生成相关问题:</think>### 解决 rsync 认证失败问题 (password mismatch, code 5) #### 问题核心分析 错误信息 `auth failed on module data` 和 `password mismatch` 表明 rsync 服务端与客户端密码不匹配,具体原因如下: 1. **密码文件格式错误**:服务端与客户端密码文件格式要求不同 2. **模块配置不一致**:`[data]` 模块的认证用户未正确定义 3. **环境干扰**:SSH 配置文件输出干扰协议通信[^2] --- ### 分步解决方案 #### 步骤 1:验证密码文件格式 | 位置 | 正确格式 | 错误示例 | |------------|--------------------------|--------------------------| | **服务端**<br>(`/etc/rsyncd.secrets`) | `用户名:密码`<br>例:`rsync_backup:Passw0rd!` | `rsync_backup=Passw0rd!` | | **客户端**<br>(`/etc/rsync.passwd`) | 纯密码<br>例:`Passw0rd!` | `rsync_backup:Passw0rd!` | ```bash # 服务端验证 sudo cat /etc/rsyncd.secrets # 客户端验证 sudo cat /etc/rsync.passwd ``` #### 步骤 2:检查模块配置 确认服务端 `/etc/rsyncd.conf` 配置: ```ini [data] path = /srv/backup # 实际备份目录 auth users = rsync_backup # 必须与密码文件用户名一致 secrets file = /etc/rsyncd.secrets read only = no # 允许写入 ``` 关键检查点: ```bash # 确保模块加载 sudo rsync --daemon --config=/etc/rsyncd.conf --no-detach # 正常输出:listening on [0.0.0.0]:873 ``` #### 步骤 3:修复环境干扰 禁用 SSH 配置文件输出: ```bash # 在服务端执行 (10.0.0.41) sed -i 's/^ *echo/#echo/g' ~/.bashrc ~/.profile ``` #### 步骤 4:权限与日志配置 ```bash # 统一密码文件权限 sudo chmod 600 /etc/rsyncd.secrets /etc/rsync.passwd sudo chown root:root /etc/rsyncd.secrets # 启用详细日志 (服务端) echo "log file = /var/log/rsyncd.log" | sudo tee -a /etc/rsyncd.conf sudo systemctl restart rsyncd ``` #### 步骤 5:连接测试 ```bash # 客户端测试命令 (详细模式) rsync -avv --password-file=/etc/rsync.passwd \ /tmp/testfile rsync_backup@10.0.0.41::data # 查看服务端日志 sudo tail -f /var/log/rsyncd.log ``` **成功标志**: ``` > sending incremental file list > testfile > sent 102 bytes received 35 bytes 274.00 bytes/sec ``` --- ### 错误排查表 | 错误现象 | 解决方案 | |--------------------------|----------------------------------| | **password mismatch** | 检查步骤1的格式差异 | | **code 5 protocol error**| 执行步骤3禁用.bashrc输出[^2] | | **Unknown module 'data'**| 确认服务端配置存在`[data]`模块 | | **Permission denied** | `chmod 600` 密码文件 | > ⚠️ **注意**:服务端密码文件必须使用`用户名:密码`格式,客户端只需纯密码 --- ### 总结关键点 1. **格式差异**:服务端 `用户:密码` vs 客户端 `纯密码` 2. **环境净化**:禁用 `.bashrc` 中的输出语句[^2] 3. **权限最小化**:所有密码文件设为 `600` 权限 4. **日志优先**:通过 `/var/log/rsyncd.log` 获取具体错误
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值