0

I want a production server to push backup files to a backup machine. Backups are being done via www-data cron script (as they can be edited by website cms), and once it has finished the idea is to send this files to backup server via rsync & ssh. www-data is a 'no login user' account (no home, no ~/.ssh folder).

In a 'user can login' account I would login, generate a certificate with ssh-keygen and place public key into .ssh/authorized_keys in backup machine.

How can I make this 'user no login' account to send files to remote machine with rsync and ssh?

1

How can I make this 'user no login' account to send files to remote machine with rsync and ssh?

you can try something like the following

# su -l www-data -s '/bin/bash' -c 'rsync -rzav --rsh="ssh -p 22 -i user_can_login_private.key -o StrictHostKeyChecking=no" /var/www/html/ user_can_login@{backup_machine_ip}:/backup/html/'
  • Thanks! In fact, as this script is already being ran by www-data user cron, the script would be something like: cmd="rsync -rzav --rsh='ssh -p ${sshPort} -i ${bkPrivateKeyFile} -o StrictHostKeyChecking=no' ${bkFilePath} user@${backupIp}:/backup/${bkFileName}" – Miquel Feb 19 '16 at 6:39

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.