# Enter as root or use sudoroot@senseBackup:~# adduser rbackupAdding user `rbackup' ...Adding new group `rbackup' (1002) ...Adding new user `rbackup' (1002) with group `rbackup' ...Creating home directory `/home/rbackup' ...Copying files from `/etc/skel' ...Enter new UNIX password: ***Retype new UNIX password: ***passwd: password updated successfullyChanging the user information for rbackupEnter the new value, or press ENTER for the default Full Name []: Remote Backup User for *sense systems Room Number []: Work Phone []: Home Phone []: Other []:Is the information correct? [Y/n] Y# switch to new userroot@senseBackup:~# su - rbackup# create ED25519 keyrbackup@senseBackup:~$ ssh-keygen -t ed25519Generating public/private ed25519 key pair.Enter file in which to save the key (/home/rbackup/.ssh/id_ed25519): <ENTER>Enter passphrase (empty for no passphrase): <ENTER>Enter same passphrase again: <ENTER>Your identification has been saved in /home/rbackup/.ssh/id_ed25519.Your public key has been saved in /home/rbackup/.ssh/id_ed25519.pub.The key fingerprint is:da:82:4c:cc:e3:e9:c7:ef:ad:96:45:58:c0:4f:46:49 rbackup@senseBackupThe key's randomart image is:+--[ED25519 256--+| ..+E. || . = || * || o . o || = S. || + + o . || =.o .o || . o.o. || .. ++.. |+-----------------+# copy public key to authorized_keys for pw-less connectrbackup@senseBackup:~$ cp .ssh/id_ed25519.pub .ssh/authorized_keys
# copy SSH key to *sense system:rbackup@senseBackup:~$ scp .ssh/id_ed25519* <senseIP>:~/.ssh/Password for rbackup@OPNsense.localdomain: ***id_ed25519 100% 411 0.4KB/s 00:00id_ed25519.pub 100% 97 0.1KB/s 00:00# connect to *sense with SSH again...rbackup@senseBackup:~$ ssh 10.0.200.223Password for rbackup@OPNsense.localdomain: ***Last login: Tue Mar 6 10:58:44 2018 from 10.100.250.250----------------------------------------------| Hello, this is OPNsense 18.1 | @@@@@@@@@@@@@@@| | @@@@ @@@@| Website: https://opnsense.org/ | @@@\\\ ///@@@| Handbook: https://docs.opnsense.org/ | )))))))) ((((((((| Forums: https://forum.opnsense.org/ | @@@/// \\\@@@| Lists: https://lists.opnsense.org/ | @@@@ @@@@| Code: https://github.com/opnsense | @@@@@@@@@@@@@@@----------------------------------------------# now test connection back to the backup-system:rbackup@OPNsense:~ % ssh <senseBackup-IP>The authenticity of host '<senseBackup-IP> (<senseBackup-IP>)' can't be established.ECDSA key fingerprint is SHA256:TFXVlGG5SwrM/wyWxNSu3NmWtgY8t9w+wxDk39mGL7Q.No matching host key fingerprint found in DNS.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '10.100.250.250' (ECDSA) to the list of known hosts.rbackup@senseBackup:~$# it's working!# add a directory or directory structure for your backup(s)rbackup@senseBackup:~$ mkdir -p opnsense/<hostname># exit Backup systemrbackup@senseBackup:~$ exit# back on OPNsense system test backing up via simple one-liner:rbackup@OPNsense:~ % scp /conf/config.xml <senseBackup-IP>:~/opnsense/<hostname>/config.xml 100% 57KB 19.2MB/s 00:00# should copy without asking for password# now exit back to the senseBackup system:rbackup@OPNsense:~ % exit# check for backup file:rbackup@senseBackup:~$ ls -la opnsense/<hostname>/total 68drwxrwxr-x 2 rbackup rbackup 4096 Mar 6 11:32 .drwxrwxr-x 3 rbackup rbackup 4096 Mar 6 11:31 ..-rw-r--r-- 1 rbackup rbackup 58792 Mar 6 11:32 config.xml
# edit user rbackups crontabrbackup@OPNsense:~ # crontab -e# add the following lines to the bottom of the file:# rbackup configuration backup to senseBackup:5 <tab> 0,12 <tab> * <tab> * <tab> * <tab> scp /conf/config.xml <senseBackup-IP>:~/opnsense/<hostname>/### example:5 0 * * * scp /conf/config.xml 10.0.0.123:~/opnsense/fw01/