简体   繁体   English

服务器上的Rsync远程文件夹,密码为本地文件夹

[英]Rsync remote folder on a server with password to local folder

I am trying to rsync folders in a remote directory on a server with password to a local directory. 我正在尝试使用密码将本地目录的密码同步到服务器上远程目录中的文件夹。 SCP works but I am not able to get the right rsync command working. SCP工作正常,但是我无法使正确的rsync命令正常工作。 I get directory not found or "not a directory" error. 我得到找不到目录或“不是目录”的错误。

I am trying: 我在尝试:

rsync -ratlz --rsh="/usr/bin/sshpass -p $RSYNC_PASSWORD ssh -o StrictHostKeyChecking=no -l adminuser@xxx.xx.xxx.xxx" $serverpath/* $localpath/

$serverpath has many directories with files inside of them. $ serverpath有许多目录,其中包含文件。

The scp that works for me is : 对我有用的scp是:

for latestfile in `sshpass -p $RSYNC_PASSWORD ssh adminuser@xxx.xx.xxx.xxx ls -ltr -d ${serverpath}/*`
do

sshpass -p "$RSYNC_PASSWORD" scp -r adminuser@xxx.xx.xxx.xxx:$serverpath/$latestfile $localpath/

done

Any help would be appreciated. 任何帮助,将不胜感激。

Thanks 谢谢

I managed to get it working. 我设法使它起作用。 It is necessary to include hostname with server path separately. 必须在服务器路径中单独包含主机名。 sshpass requires user login credentials and IP of remote server as a part of the ssh command and shoudl be included it in the rsync command. sshpass要求用户登录凭据和远程服务器的IP作为ssh命令的一部分,并将shoudl包含在rsync命令中。

rsync -avzr -e "sshpass -p $RSYNC_PASSWORD ssh -l adminuser@xxx.xx.xxx.xxx"  adminuser@xxx.xx.xxx.xxx:$serverpath/*  $localpath/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM