{"id":4652,"date":"2022-12-20T18:09:27","date_gmt":"2022-12-20T21:09:27","guid":{"rendered":"http:\/\/lode.uno\/linux-man\/index.php\/2022\/12\/20\/crypttab-man5\/"},"modified":"2022-12-20T18:09:27","modified_gmt":"2022-12-20T21:09:27","slug":"crypttab-man5","status":"publish","type":"post","link":"https:\/\/lode.uno\/linux-man\/2022\/12\/20\/crypttab-man5\/","title":{"rendered":"CRYPTTAB (man5)"},"content":{"rendered":"<h1 align=\"center\">CRYPTTAB<\/h1>\n<p> <a href=\"#NAME\">NAME<\/a><br \/> <a href=\"#SYNOPSIS\">SYNOPSIS<\/a><br \/> <a href=\"#DESCRIPTION\">DESCRIPTION<\/a><br \/> <a href=\"#EXAMPLES\">EXAMPLES<\/a><br \/> <a href=\"#SEE ALSO\">SEE ALSO<\/a><br \/> <a href=\"#NOTES\">NOTES<\/a> <\/p>\n<hr>\n<h2>NAME <a name=\"NAME\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">crypttab \u2212 Configuration for encrypted block devices<\/p>\n<h2>SYNOPSIS <a name=\"SYNOPSIS\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">\/etc\/crypttab<\/p>\n<h2>DESCRIPTION <a name=\"DESCRIPTION\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\">The \/etc\/crypttab file describes encrypted block devices that are set up during system boot.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Empty lines and lines starting with the &#8220;#&#8221; character are ignored. Each of the remaining lines describes one encrypted block device. Fields are delimited by white space.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Each line is in the form<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><i>volume\u2212name encrypted\u2212device key\u2212file options<\/i><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The first two fields are mandatory, the remaining two are optional.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">Setting up encrypted block devices using this file supports three encryption modes: LUKS, TrueCrypt and plain. See <b>cryptsetup<\/b>(8) for more information about each mode. When no mode is specified in the options field and the block device contains a LUKS signature, it is opened as a LUKS device; otherwise, it is assumed to be in raw dm\u2212crypt (plain mode) format.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The first field contains the name of the resulting encrypted volume; its block device is set up below \/dev\/mapper\/.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The second field contains a path to the underlying block device or file, or a specification of a block device via &#8220;UUID=&#8221; followed by the UUID.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The third field specifies an absolute path to a file to read the encryption key from. Optionally, the path may be followed by &#8220;:&#8221; and an fstab device specification (e.g. starting with &#8220;LABEL=&#8221; or similar); in which case, the path is relative to the device file system root. If the field is not present or set to &#8220;none&#8221; or &#8220;\u2212&#8221;, a key file named after the volume to unlock (i.e. the first column of the line), suffixed with .key is automatically loaded from the \/etc\/cryptsetup\u2212keys.d\/ and \/run\/cryptsetup\u2212keys.d\/ directories, if present. Otherwise, the password has to be manually entered during system boot. For swap encryption, \/dev\/urandom may be used as key file.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\">The fourth field, if present, is a comma\u2212delimited list of options. The following options are recognized:<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>cipher=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the cipher to use. See <b>cryptsetup<\/b>(8) for possible values and the default value of this option. A cipher with unpredictable IV values, such as &#8220;aes\u2212cbc\u2212essiv:sha256&#8221;, is recommended.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>discard<\/b><\/p>\n<p style=\"margin-left:17%;\">Allow discard requests to be passed through the encrypted block device. This improves performance on SSD storage but has security implications.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>hash=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the hash to use for password hashing. See <b>cryptsetup<\/b>(8) for possible values and the default value of this option.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>header=<\/b><\/p>\n<p style=\"margin-left:17%;\">Use a detached (separated) metadata device or file where the LUKS header is stored. This option is only relevant for LUKS devices. See <b>cryptsetup<\/b>(8) for possible values and the default value of this option.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>keyfile\u2212offset=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the number of bytes to skip at the start of the key file. See <b>cryptsetup<\/b>(8) for possible values and the default value of this option.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>keyfile\u2212size=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the maximum number of bytes to read from the key file. See <b>cryptsetup<\/b>(8) for possible values and the default value of this option. This option is ignored in plain encryption mode, as the key file size is then given by the key size.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>keyfile\u2212erase<\/b><\/p>\n<p style=\"margin-left:17%;\">If enabled, the specified key file is erased after the volume is activated or when activation fails. This is in particular useful when the key file is only acquired transiently before activation (e.g. via a file in \/run\/, generated by a service running before activation), and shall be removed after use. Defaults to off.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>key\u2212slot=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the key slot to compare the passphrase or key against. If the key slot does not match the given passphrase or key, but another would, the setup of the device will fail regardless. This option implies <b>luks<\/b>. See <b>cryptsetup<\/b>(8) for possible values. The default is to try all key slots in sequential order.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>keyfile\u2212timeout=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the timeout for the device on which the key file resides and falls back to a password if it could not be mounted. See <b>systemd-cryptsetup-generator<\/b>(8) for key files on external devices.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>luks<\/b><\/p>\n<p style=\"margin-left:17%;\">Force LUKS mode. When this mode is used, the following options are ignored since they are provided by the LUKS header on the device: <b>cipher=<\/b>, <b>hash=<\/b>, <b>size=<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>bitlk<\/b><\/p>\n<p style=\"margin-left:17%;\">Decrypt Bitlocker drive. Encryption parameters are deduced by cryptsetup from Bitlocker header.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>_netdev<\/b><\/p>\n<p style=\"margin-left:17%;\">Marks this cryptsetup device as requiring network. It will be started after the network is available, similarly to <b>systemd.mount<\/b>(5) units marked with <b>_netdev<\/b>. The service unit to set up this device will be ordered between remote\u2212fs\u2212pre.target and remote\u2212cryptsetup.target, instead of cryptsetup\u2212pre.target and cryptsetup.target.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Hint: if this device is used for a mount point that is specified in <b>fstab<\/b>(5), the <b>_netdev<\/b> option should also be used for the mount point. Otherwise, a dependency loop might be created where the mount point will be pulled in by local\u2212fs.target, while the service to configure the network is usually only started <i>after<\/i> the local file system has been mounted.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>noauto<\/b><\/p>\n<p style=\"margin-left:17%;\">This device will not be added to cryptsetup.target. This means that it will not be automatically unlocked on boot, unless something else pulls it in. In particular, if the device is used for a mount point, it&#8217;ll be unlocked automatically during boot, unless the mount point itself is also disabled with <b>noauto<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>nofail<\/b><\/p>\n<p style=\"margin-left:17%;\">This device will not be a hard dependency of cryptsetup.target. It&#8217;ll still be pulled in and started, but the system will not wait for the device to show up and be unlocked, and boot will not fail if this is unsuccessful. Note that other units that depend on the unlocked device may still fail. In particular, if the device is used for a mount point, the mount point itself also needs to have the <b>nofail<\/b> option, or the boot will fail if the device is not unlocked successfully.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>offset=<\/b><\/p>\n<p style=\"margin-left:17%;\">Start offset in the backend device, in 512\u2212byte sectors. This option is only relevant for plain devices.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>plain<\/b><\/p>\n<p style=\"margin-left:17%;\">Force plain encryption mode.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>read\u2212only<\/b>, <b>readonly<\/b><\/p>\n<p style=\"margin-left:17%;\">Set up the encrypted block device in read\u2212only mode.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>same\u2212cpu\u2212crypt<\/b><\/p>\n<p style=\"margin-left:17%;\">Perform encryption using the same cpu that IO was submitted on. The default is to use an unbound workqueue so that encryption work is automatically balanced between available CPUs.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This requires kernel 4.0 or newer.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>submit\u2212from\u2212crypt\u2212cpus<\/b><\/p>\n<p style=\"margin-left:17%;\">Disable offloading writes to a separate thread after encryption. There are some situations where offloading write requests from the encryption threads to a dedicated thread degrades performance significantly. The default is to offload write requests to a dedicated thread because it benefits the CFQ scheduler to have writes submitted using the same context.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This requires kernel 4.0 or newer.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>no\u2212read\u2212workqueue<\/b><\/p>\n<p style=\"margin-left:17%;\">Bypass dm\u2212crypt internal workqueue and process read requests synchronously. The default is to queue these requests and process them asynchronously.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This requires kernel 5.9 or newer.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>no\u2212write\u2212workqueue<\/b><\/p>\n<p style=\"margin-left:17%;\">Bypass dm\u2212crypt internal workqueue and process write requests synchronously. The default is to queue these requests and process them asynchronously.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This requires kernel 5.9 or newer.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>skip=<\/b><\/p>\n<p style=\"margin-left:17%;\">How many 512\u2212byte sectors of the encrypted data to skip at the beginning. This is different from the <b>offset=<\/b> option with respect to the sector numbers used in initialization vector (IV) calculation. Using <b>offset=<\/b> will shift the IV calculation by the same negative amount. Hence, if <b>offset=<\/b><i>n<\/i> is given, sector <i>n<\/i> will get a sector number of 0 for the IV calculation. Using <b>skip=<\/b> causes sector <i>n<\/i> to also be the first sector of the mapped device, but with its number for IV generation being <i>n<\/i>.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This option is only relevant for plain devices.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>size=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the key size in bits. See <b>cryptsetup<\/b>(8) for possible values and the default value of this option.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>sector\u2212size=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the sector size in bytes. See <b>cryptsetup<\/b>(8) for possible values and the default value of this option.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>swap<\/b><\/p>\n<p style=\"margin-left:17%;\">The encrypted block device will be used as a swap device, and will be formatted accordingly after setting up the encrypted block device, with <b>mkswap<\/b>(8). This option implies <b>plain<\/b>.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">WARNING: Using the <b>swap<\/b> option will destroy the contents of the named partition during every boot, so make sure the underlying block device is specified correctly.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tcrypt<\/b><\/p>\n<p style=\"margin-left:17%;\">Use TrueCrypt encryption mode. When this mode is used, the following options are ignored since they are provided by the TrueCrypt header on the device or do not apply: <b>cipher=<\/b>, <b>hash=<\/b>, <b>keyfile\u2212offset=<\/b>, <b>keyfile\u2212size=<\/b>, <b>size=<\/b>.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">When this mode is used, the passphrase is read from the key file given in the third field. Only the first line of this file is read, excluding the new line character.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">Note that the TrueCrypt format uses both passphrase and key files to derive a password for the volume. Therefore, the passphrase and all key files need to be provided. Use <b>tcrypt\u2212keyfile=<\/b> to provide the absolute path to all key files. When using an empty passphrase in combination with one or more key files, use &#8220;\/dev\/null&#8221; as the password file in the third field.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tcrypt\u2212hidden<\/b><\/p>\n<p style=\"margin-left:17%;\">Use the hidden TrueCrypt volume. This option implies <b>tcrypt<\/b>.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">This will map the hidden volume that is inside of the volume provided in the second field. Please note that there is no protection for the hidden volume if the outer volume is mounted instead. See <b>cryptsetup<\/b>(8) for more information on this limitation.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tcrypt\u2212keyfile=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the absolute path to a key file to use for a TrueCrypt volume. This implies <b>tcrypt<\/b> and can be used more than once to provide several key files.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">See the entry for <b>tcrypt<\/b> on the behavior of the passphrase and key files when using TrueCrypt encryption mode.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tcrypt\u2212system<\/b><\/p>\n<p style=\"margin-left:17%;\">Use TrueCrypt in system encryption mode. This option implies <b>tcrypt<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tcrypt\u2212veracrypt<\/b><\/p>\n<p style=\"margin-left:17%;\">Check for a VeraCrypt volume. VeraCrypt is a fork of TrueCrypt that is mostly compatible, but uses different, stronger key derivation algorithms that cannot be detected without this flag. Enabling this option could substantially slow down unlocking, because VeraCrypt&#8217;s key derivation takes much longer than TrueCrypt&#8217;s. This option implies <b>tcrypt<\/b>.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>timeout=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the timeout for querying for a password. If no unit is specified, seconds is used. Supported units are s, ms, us, min, h, d. A timeout of 0 waits indefinitely (which is the default).<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tmp=<\/b><\/p>\n<p style=\"margin-left:17%;\">The encrypted block device will be prepared for using it as \/tmp\/; it will be formatted using <b>mkfs<\/b>(8). Takes a file system type as argument, such as &#8220;ext4&#8221;, &#8220;xfs&#8221; or &#8220;btrfs&#8221;. If no argument is specified defaults to &#8220;ext4&#8221;. This option implies <b>plain<\/b>.<\/p>\n<p style=\"margin-left:17%; margin-top: 1em\">WARNING: Using the <b>tmp<\/b> option will destroy the contents of the named partition during every boot, so make sure the underlying block device is specified correctly.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>tries=<\/b><\/p>\n<p style=\"margin-left:17%;\">Specifies the maximum number of times the user is queried for a password. The default is 3. If set to 0, the user is queried for a password indefinitely.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>verify<\/b><\/p>\n<p style=\"margin-left:17%;\">If the encryption password is read from console, it has to be entered twice to prevent typos.<\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><b>pkcs11\u2212uri=<\/b><\/p>\n<p style=\"margin-left:17%;\">Takes a <b><font color=\"#0000FF\">RFC7512 PKCS#11 URI<\/font><\/b> <small><font color=\"#000000\">[1]<\/font><\/small> <font color=\"#000000\">pointing to a private RSA key which is used to decrypt the key specified in the third column of the line. This is useful for unlocking encrypted volumes through security tokens or smartcards. See below for an example how to set up this mechanism for unlocking a LUKS volume with a YubiKey security token. The specified URI can refer directly to a private RSA key stored on a token or alternatively just to a slot or token, in which case a search for a suitable private RSA key will be performed. In this case if multiple suitable objects are found the token is refused. The key configured in the third column is passed as is to RSA decryption. The resulting decrypted key is then base64 encoded before it is used to unlock the LUKS volume.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>try\u2212empty\u2212password=<\/b><\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">Takes a boolean argument. If enabled, right before asking the user for a password it is first attempted to unlock the volume with an empty password. This is useful for systems that are initialized with an encrypted volume with only an empty password set, which shall be replaced with a suitable password during first boot, but after activation.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>x\u2212systemd.device\u2212timeout=<\/b><\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">Specifies how long systemd should wait for a device to show up before giving up on the entry. The argument is a time in seconds or explicitly specified units of &#8220;s&#8221;, &#8220;min&#8221;, &#8220;h&#8221;, &#8220;ms&#8221;.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>x\u2212initrd.attach<\/b><\/font><\/p>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">Setup this encrypted block device in the initramfs, similarly to <b>systemd.mount<\/b>(5) units marked with <b>x\u2212initrd.mount<\/b>.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">Although it&#8217;s not necessary to mark the mount entry for the root file system with <b>x\u2212initrd.mount<\/b>, <b>x\u2212initrd.attach<\/b> is still recommended with the encrypted block device containing the root file system as otherwise systemd will attempt to detach the device during the regular system shutdown while it&#8217;s still in use. With this option the device will still be detached but later after the root file system is unmounted.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">All other encrypted block devices that contain file systems mounted in the initramfs should use this option.<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">At early boot and when the system manager configuration is reloaded, this file is translated into native systemd units by <b>systemd-cryptsetup-generator<\/b>(8).<\/font><\/p>\n<h2>EXAMPLES <a name=\"EXAMPLES\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>Example\u00a01.\u00a0\/etc\/crypttab example<\/b><\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">Set up four encrypted block devices. One using LUKS for normal storage, another one for usage as a swap device and two TrueCrypt volumes.<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">luks UUID=2505567a\u22129e27\u22124efe\u2212a4d5\u221215ad146c258b <br \/> swap \/dev\/sda7 \/dev\/urandom swap <br \/> truecrypt \/dev\/sda2 \/etc\/container_password tcrypt <br \/> hidden \/mnt\/tc_hidden \/dev\/null tcrypt\u2212hidden,tcrypt\u2212keyfile=\/etc\/keyfile <br \/> external \/dev\/sda3 keyfile:LABEL=keydev keyfile\u2212timeout=10s<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>Example\u00a02.\u00a0Yubikey\u2212based Volume Unlocking Example<\/b><\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">The PKCS#11 logic allows hooking up any compatible security token that is capable of storing RSA decryption keys. Here&#8217;s an example how to set up a Yubikey security token for this purpose, using <b>ykmap<\/b>(1) from the yubikey\u2212manager project:<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Make sure no one can read the files we generate but us <br \/> umask 077<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Destroy any old key on the Yubikey (careful!) <br \/> ykman piv reset<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Generate a new private\/public key pair on the device, store the public key in &#8216;pubkey.pem&#8217;. <br \/> ykman piv generate\u2212key \u2212a RSA2048 9d pubkey.pem<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Create a self\u2212signed certificate from this public key, and store it on the <br \/> # device. The &#8220;subject&#8221; should be an arbitrary string to identify the token in <br \/> # the p11tool output below. <br \/> ykman piv generate\u2212certificate \u2212\u2212subject &#8220;Knobelei&#8221; 9d pubkey.pem<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Check if the newly create key on the Yubikey shows up as token in PKCS#11. Have a look at the output, and <br \/> # copy the resulting token URI to the clipboard. <br \/> p11tool \u2212\u2212list\u2212tokens<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Generate a (secret) random key to use as LUKS decryption key. <br \/> dd if=\/dev\/urandom of=plaintext.bin bs=128 count=1<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Encode the secret key also as base64 text (with all whitespace removed) <br \/> base64 < plaintext.bin | tr \u2212d 'nrt ' > plaintext.base64<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Encrypt this newly generated (binary) LUKS decryption key using the public key whose private key is on the <br \/> # Yubikey, store the result in \/etc\/cryptsetup\u2212keys.d\/mytest.key, where we&#8217;ll look for it during boot. <br \/> mkdir \u2212p \/etc\/cryptsetup\u2212keys.d <br \/> sudo openssl rsautl \u2212encrypt \u2212pubin \u2212inkey pubkey.pem \u2212in plaintext.bin \u2212out \/etc\/cryptsetup\u2212keys.d\/mytest.key<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Configure the LUKS decryption key on the LUKS device. We use very low pbkdf settings since the key already <br \/> # has quite a high quality (it comes directly from \/dev\/urandom after all), and thus we don&#8217;t need to do much <br \/> # key derivation. Replace \/dev\/sdXn by the partition to use (e.g. sda1) <br \/> sudo cryptsetup luksAddKey \/dev\/sdXn plaintext.base64 \u2212\u2212pbkdf=pbkdf2 \u2212\u2212pbkdf\u2212force\u2212iterations=1000<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Now securely delete the plain text LUKS key, we don&#8217;t need it anymore, and since it contains secret key <br \/> # material it should be removed from disk thoroughly. <br \/> shred \u2212u plaintext.bin plaintext.base64<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># We don&#8217;t need the public key anymore either, let&#8217;s remove it too. Since this one is not security <br \/> # sensitive we just do a regular &#8220;rm&#8221; here. <br \/> rm pubkey.pem<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># Test: Let&#8217;s run systemd\u2212cryptsetup to test if this all worked. The option string should contain the full <br \/> # PKCS#11 URI we have in the clipboard; it tells the tool how to decipher the encrypted LUKS key. Note that <br \/> # systemd\u2212cryptsetup automatically searches for the encrypted key in \/etc\/cryptsetup\u2212keys.d\/, hence we do <br \/> # not need to specify the key file path explicitly here. <br \/> sudo systemd\u2212cryptsetup attach mytest \/dev\/sdXn \u2212 &#8216;pkcs11\u2212uri=pkcs11:&#8230;&#8217;<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\"># If that worked, let&#8217;s now add the same line persistently to \/etc\/crypttab, for the future. <br \/> sudo bash \u2212c &#8216;echo &#8220;mytest \/dev\/sdXn \u2212 &#8216;pkcs11\u2212uri=pkcs11:&#8230;'&#8221; >> \/etc\/crypttab&#8217;<\/font><\/p>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\">A few notes on the above:<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">\u2022 We use RSA (and not ECC), since Yubikeys support PKCS#11 Decrypt() only for RSA keys<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">\u2022 We use RSA2048, which is the longest key size current Yubikeys support<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">\u2022 LUKS key size must be shorter than 2048bit due to RSA padding, hence we use 128 bytes<\/font><\/p>\n<p style=\"margin-left:17%; margin-top: 1em\"><font color=\"#000000\">\u2022 We use Yubikey key slot 9d, since that&#8217;s apparently the keyslot to use for decryption purposes,<\/font> <b><font color=\"#0000FF\">see documentation<\/font><\/b> <small><font color=\"#000000\">[2]<\/font><\/small> <font color=\"#000000\">.<\/font><\/p>\n<h2>SEE ALSO <a name=\"SEE ALSO\"><\/a> <\/h2>\n<p style=\"margin-left:11%; margin-top: 1em\"><font color=\"#000000\"><b>systemd<\/b>(1), <b>systemd-cryptsetup@.service<\/b>(8), <b>systemd-cryptsetup-generator<\/b>(8), <b>fstab<\/b>(5), <b>cryptsetup<\/b>(8), <b>mkswap<\/b>(8), <b>mke2fs<\/b>(8)<\/font><\/p>\n<h2>NOTES <a name=\"NOTES\"><\/a> <\/h2>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">1.<\/font><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"29%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">RFC7512 PKCS#11 URI<\/font><\/p>\n<\/td>\n<td width=\"54%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">https:\/\/tools.ietf.org\/html\/rfc7512<\/font><\/p>\n<table width=\"100%\" border=\"0\" rules=\"none\" frame=\"void\" cellspacing=\"0\" cellpadding=\"0\">\n<tr valign=\"top\" align=\"left\">\n<td width=\"12%\"><\/td>\n<td width=\"3%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">2.<\/font><\/p>\n<\/td>\n<td width=\"2%\"><\/td>\n<td width=\"26%\">\n<p style=\"margin-top: 1em\"><font color=\"#000000\">see documentation<\/font><\/p>\n<\/td>\n<td width=\"57%\"> <\/td>\n<\/tr>\n<\/table>\n<p style=\"margin-left:17%;\"><font color=\"#000000\">https:\/\/developers.yubico.com\/PIV\/Introduction\/Certificate_slots.html<\/font><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>  crypttab \u2212 Configuration for encrypted block devices <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[959],"tags":[961,1587,1291],"class_list":["post-4652","post","type-post","status-publish","format-standard","hentry","category-5-formatos-de-ficheros","tag-961","tag-crypttab","tag-man5"],"gutentor_comment":0,"_links":{"self":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/comments?post=4652"}],"version-history":[{"count":0,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/posts\/4652\/revisions"}],"wp:attachment":[{"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/media?parent=4652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/categories?post=4652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lode.uno\/linux-man\/wp-json\/wp\/v2\/tags?post=4652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}