0

how can I automount an encrypted USB device (e.g. USB stick) via key file, when connected.

What I did so far

It works during boot time. The device will be encrypted via keyfile and mounted in /mnt/usb, even if the device is not connected, no error message appears because of the nofail parameter:

sudo dd if=/dev/urandom of=/etc/usb.keyfile bs=1024 count=4 
sudo chmod 400 /etc/usb.keyfile 
sudo cryptsetup luksAddKey /dev/sdb /etc/usb.keyfile
sudo mkdir /mnt/usb
sudo blkid /dev/sdb 

# /etc/crypttab
usb_crypt UUID=f0d1d710-34bf-4bc2-8875-90595a6db3f6 /etc/usb.keyfile luks,nofail 

# /etc/fstab
/dev/mapper/usb_crypt /mnt/usb ext4 defaults,nofail 0 2 

What is missing

When I connect the device after startup, on my running system, a window appears, which ask me for the key. Here I would expect that the device will be encrypted/mounted automatically via key file.

My system

Ubuntu 22.04.4 LTS

0

You must log in to answer this question.

Browse other questions tagged .