加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

bash – 脚本中rsync的用户名和密码

发布时间:2020-12-15 18:36:26 所属栏目:安全 来源:网络整理
导读:我正在创建一个cron作业,以保持两个目录同步.我正在使用rsync.我正在运行一个rsync守护进程.我阅读了手册并说: RSYNC_PASSWORD Setting RSYNC_PASSWORD to the required password allows you to run authenticated rsync connections to an rsync daemon wi
我正在创建一个cron作业,以保持两个目录同步.我正在使用rsync.我正在运行一个rsync守护进程.我阅读了手册并说:
RSYNC_PASSWORD
          Setting  RSYNC_PASSWORD  to  the required password allows you to
          run authenticated rsync connections to an rsync  daemon  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 daemon.  If neither is
          set,the username defaults to 'nobody'

我有类似的东西:

#!/bin/bash
USER=name
RSYNC_PASSWORD=pass
DEST="myhost::mymodule"

/usr/bin/rsync -rltvvv . $DEST

我也试过导出(危险,我知道)USER和RSYNC_PASSWORD.我也尝试过使用LOGNAME.什么都行不通.我这样做了吗?

编辑(澄清)

我在linux下使用rsync版本2.6.9.

此命令有效:

/usr/bin/rsync -rltvvv . myuser@myhost::mymodule

我被提示输入密码,当我输入密码时,传输开始.

这是我通过脚本尝试时遇到的错误:

opening tcp connection to myhost port 873
opening connection using --server -vvvltr . mymodule
@ERROR: auth failed on module mymodule
rsync error: error starting client-server protocol (code 5) at main.c(1383) [sender=2.6.9]
_exit_cleanup(code=5,file=main.c,line=1383): about to call exit(5)
你尝试过类似的东西:
rsync -rltvvv --password-file=/root/secret . user@host::dest

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读