Sample Header Ad - 728x90

how to let the systemd cryptsetup automatically mount the usb key which contain keyfile?

3 votes
1 answer
3082 views
In ubuntu 19.10 I followed the example here . The keyfile is at the root of usb key filesystem. usbkey has uuid yyyy. the /etc/crypttab is like this:
encrypted UUID=xxxx /keyfile:UUID=yyyy luks,keyfile-timeout=60,x-systemd.device-timeout=2min
The automatically generated generator is /run/systemd/generator/systemd-cryptsetup@encrypted.service
# Automatically generated by systemd-cryptsetup-generator

[Unit]
Description=Cryptography Setup for %I
Documentation=man:crypttab(5) man:systemd-cryptsetup-generator(8) man:systemd-cryptsetup@.service(8)
SourcePath=/etc/crypttab
DefaultDependencies=no
Conflicts=umount.target
IgnoreOnIsolate=true
After=cryptsetup-pre.target
Before=cryptsetup.target
RequiresMountsFor=/keyfile:UUID=yyyy
BindsTo=dev-disk-by\x2duuid-xxxx.device
After=dev-disk-by\x2duuid-xxxx.device
Before=umount.target

[Service]
Type=oneshot
RemainAfterExit=yes
TimeoutSec=0
KeyringMode=shared
OOMScoreAdjust=500
ExecStart=/lib/systemd/systemd-cryptsetup attach 'encrypted' '/dev/disk/by-uuid/xxxx' '/keyfile:UUID=yyyy' 'luks,keyfile-timeout=60'
ExecStop=/lib/systemd/systemd-cryptsetup detach 'encrypted'
however, I did not see any thing related to mount the usb key in the journalctl. I always directly launch the system-cryptsetup and fail to find the file.
systemd-cryptsetup: Encountered unknown /etc/crypttab option 'keyfile-timeout=60', ignoring.
systemd-cryptsetup: WARNING: Locking directory /run/cryptsetup is missing!
systemd[1] : Started File System Check Daemon to report status.
systemd-cryptsetup: Set cipher aes, mode xts-plain64, key size 512 bits for device /dev/disk/by-uuid/xxxx
systemd-cryptsetup: Failed to open key file.
systemd-cryptsetup: Failed to activate with key file '/keyfile:UUID=yyyy
Asked by Wang (1395 rep)
Dec 28, 2019, 11:18 AM
Last activity: Oct 26, 2022, 08:21 PM