I am using a onedrive rclone remote included in a basic O365 subscription for my backups. As you know, this does not offer any option of immutability or append-only.
As I was worried about ransomware or an attacker also killing my cloud backups, and the other threads I found were more about special backends supporting object locks etc, I would like to create a topic to to discuss this use case, share my simple strategy, and would be happy to read about your opinions, strategies, comments, improvements etc.
Here is what I am currently doing, and it works really great:
- The rclone.conf on my NAS is encrypted with openssl AES256.
- I have a USB key lying next to the NAS, not connected. This key contains the secret to decode the rclone.conf file.
- If the system detects the connection of the USB key, rclone.conf is decrypted to ramdisk, and the cloud backup process is started. Stick can be disconnected immediately after start.
- After the backup, the ramdisk is destroyed.
My data does not change too much (mostly old photos of the kids etc.), and my NAS is mirrored, so my cloud backup is really just a ransomware insurance, and does not need to run that often. So my workflow is that every few weeks, I check a few random files to see if they are OK, and once that is done I briefly insert the stick in the NAS, just long enough to start the backup and get a notification on my phone confirming that it started.
This way, for an attacker who has access to the NAS, the rclone config is useless because it is encrypted. Regarding the USB stick, it contains a key that is also useless without the rclone config on the system, so someone stealing the stick (evil maid attack) can’t do anything with that. Oh and the NAS storage itself is encrypted too and requires me to enter a password on the initial mount after reboot, so if someone steals both NAS+Key - also useless.
Here is the outline of the concept:
# create ramdisk
/sbin/mount -t tmpfs -o size=100k tmpfs /mnt/rclone-config.decrypted
# decrypt rclone.conf
cat /path/to/encrypted/rclone.conf | openssl aes-256-cbc -d -pbkdf2 -a -pass file:/path/to/usb/stick/passfile > /mnt/rclone-config.decrypted/rclone.conf
# do backup operation here
# destroy ramdisk
- Ensuring key gets overwritten in RAM before the ramdisk is destroyed
- maybe you could even destroy the ramdisk as soon as restic spawns rclone?
- use mktemp to enable multiple instances running at the same time (I dont need this)
Another (maybe easier and even more secure) option would be to use the rclone built-in encryption, and read+set RCLONE_CONFIG_PASS before the backup, something like:
export RCLONE_CONFIG_PASS=$(cat /path/to/usb/key)
…but I only found out about rclone config encryption after I wrote my solution…