当然,不用密码是不可能的,我们平时用rsync同步文件的时候,总是用一个--password-file 指定一个密码文件,这个密码文件比较讨厌,因为这个文件的mod必须是400或者600、或者700,其他用户不能有读权限,因为这个原因,我们的dba之前两次找我,昨天写了个脚本,需要在几十台机器上部署,要是一个个来一个密码文件,岂不烦死,于是man了一下,找到了一个不用密码文件的办法,man的原型如下:
RSYNC_PASSWORD
Setting RSYNC_PASSWORD to the required password allows you to run authenticated rsync connections to an rsync dae-
mon without user intervention. Note that this does not supply a password to a shell transport such as ssh.
USER or LOGNAME
The USER or LOGNAME environment variables are used to determine the default username sent to an rsync server. If
neither is set, the username defaults to "nobody".