I have four encrypted zfs datasets that I need to mount by hand at the boot of my development machine using the command zfs mount -l -a
. These datasets all have the same password and I have to type it in four times.
Is there a way to streamline this in a secure way so I only have to type the password once? Maybe there is a secure way to have the password automatically entered?
If datasets have the same password, yet you need to enter it multiple times, this should mean that said datasets use different encryption roots/key locations; the output of
zfs get encryptionroot,keylocation <pool>/<dataset1> <pool>/<dataset2> [...]
should confirm this. You can usezfs change-key
(seeman zfs-change-key
) to unify this.To have the password entered automatically at boot time, you could use Network-Bound Disk Encryption (NBDE). Ubuntu provides packages for both Clevis and Tang, but you'd need to provide your own auxiliary script (e.g., in
/usr/share/initramfs-tools/scripts/local-premount/
) in order to ensure that the required keys are loaded. (Of course, Clevis–a pluggable framework for automated decryption–can work without Tang as well.)For automated entry of password encrypted datasets, it can be automated using
/etc/rc.local
by adding the following template script:Where:
Note: to enable
rc.local
onsystemd
enabled systems, here are some instructions.Alternatively, if you want to do this on demand, use this python script to streamline the entry of password just once:
Source for zmount.py:
To use zmount.py: