The first step is to set up the remote back up machine. For security reasons, it is better to initiate the back up from the back up machine instead of the Moodle server. It goes without saying that the back up server itself should be secure.
Add a user account just for backing up the Moodle server. This way, it is less likely to accidentally modify or delete the back up files.
Next, change user as moo using the command su moo. First, set up the SSH key for this account:
Just accept all the default settings, and do not specify a passphrase. Otherwise, it’ll be impossible to automate the back up script.
The next step involves adding the public key of moo to the user account moodle on the Moodle server. You have to append the file ~moo/.ssh/id_rsa.pub to the end of the file ~moodle/.ssh/authorized_keys. You can do this with a single command:
After this step, the user moo can authenticate to the moodle server as moodle without any interactive passwords.