8

I want to store --password-file option that comes with rsync. I don't want to use ssh public_private key encryption. I have tried this command:

rsync -avz --progress --password-file=pass.txt source destination

This says:

The --password-file option may only be used when accessing an rsync daemon.

So, I tried using:

rsync -avz --progress --password-file=pass.txt source destination rsyncd --daemon

But this return various errors like unknown options. Is my sytanx correct? How do I setup rsync daemon in my Debian machine.

1
  • "What's the syntax and prerequisite for --password-file option" is answered bellow. However, considering you added that "most of my clients may not have rsyncd.conf file or rsyncd.secrets", I'm afraid you won't be able to use that rsync option. Like I said, if you don't have permission to edit any remote files, your sole option is to use expect. Nov 23, 2012 at 8:37

3 Answers 3

6

That is correct,

--password-file is only applicable when connecting to a rsync daemon.

You probably haven't set it in the daemon itself though, the password you set and the one you use during that call must match.
Edit /etc/rsyncd.secrets, and set the owner/group of that file to root:root with world reading permissions.

#/etc/rsyncd.secrets
root:YourSecretestPassword

To connect to a rsync daemon, use a double colon followed by the module name, and the file or folder to synchronize (instead of a colon when using SSH),

RSYNC_PASSWORD="YourSecretestPassword"; rsync -rtv user@remotehost::module/source/ destination/ 

NOTE:

  • this implies abdicating SSH encryption, though the password itself is not sent across the network in plain text, your data is ...
  • this is already insecure as is, never as the the same password as any of your users account.
  • For a better understanding of its inner workings (how to give specific IPs/processes the ability to upload to specified areas of the filesystem without the need for a user account): http://transamrit.net/docs/rsync/
7
  • 1
    Tried this: RSYNC_PASSWORD="password"; rsync -rtv sachet.adhikari@ngs.pradhi.com::upload/ /home/zurelsoft Got this erro: rsync: failed to connect to ngs.pradhi.com: Connection timed out (110) rsync error: error in socket IO (code 10) at clientserver.c(122) [Receiver=3.0.7] Tried using single ":" still asks for the password. Nov 22, 2012 at 10:49
  • They are nothing more than directories, allowing you to customize permissions and tightening security. Did you read the link I mentioned? You can greatly increase your rsync with some select readings. Another one: linuxjournal.com/article/6508 Nov 22, 2012 at 10:50
  • 2
    I don't want to increase rsync for now. I just want to pass the password from the form to the terminal in the rsync. Nov 22, 2012 at 10:53
  • Also, most of my clients may not have rsyncd.conf file or rsyncd.secrets Nov 22, 2012 at 10:54
  • 1
    @JoaoFigueiredo I am having the same issue. rsync destination:: shows files file area. RSYNC_PASSWORD="password";rsync -azv /source/file root@destination::files/file. It gives error @ERROR: chroot failed. I am running rsync daemon on destination.
    – Ura
    Oct 24, 2013 at 15:25
1

After trying a while, I got this to work. Since Im copying from my live server (and routers data) to my local server in my laptop as backup user no problem with password been unencrypted, its secured wired on my laptop at home. First you need to install sshpass if Centos with yum install sshpass then create a user backup and assign a temp password. I listed the -p option in case your ssh port is different than default.

sshpass -p 'password' rsync -vaurP -e 'ssh -p 2222'  backup@???.your.ip.???:/somedir/public_data/temp/ /your/localdata/temp

Understand SSH RSA is a better permanente alternative and all that, but this is a quick alternative to backup and restore on the go. It works if you are not too concern about security but more concern about your data been backup locally as in an emergency o data recovery. Your user backup password you can change it once the backup is completed. Its a lot faster to setup when your servers change IPs, users, and its in constant modifications (as routers change config and non static IPs, also when routers are not local and you are backing up clients servers locally, where you dont have always access to do SSH. Some of my clients dont even have SSH installed and they dont want to hassle with creating public keys. On some servers only where you have access on a temporary basis. By the way, if you want to do the restore, just reverse the case. Dont need change much, from the same command shell you can do it reversing the order of target and source directories, and creating another backup user with same temp password on the target. After finish, you delete the backup user or change its passwords on target and/or source servers. You can protect even further, as I have done, replacing the password for a one line file using a bash script for multi server environment. Alternative is to use the -f option so the password does not show in the bash history -f "/path/to/passwordfile" Regards

NOTE: If you want to update only modified files then you should use this parameters -h -v -r -P -t as described here https://unix.stackexchange.com/questions/67539/how-to-rsync-only-new-files

1
  • By the way. I have been force to use this useful command, because Im backing up routers configurations and data. Routers use a very limited amount of linux commands, and this one is available on the models we are using. We tryied to use SSH keys but routers dont have permanent memory, once they reinicialize, all keys wiped out. So this work for us. Dec 16, 2018 at 14:35
0
rsync -arv -e \
    "sshpass -f '/your/pass.txt' ssh -o StrictHostKeyChecking=no" \
    --progress /your/source id@IP:/your/destination

Maybe you have to install "sshpass" if you not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.