]>
Commit | Line | Data |
---|---|---|
45ae1a05 LP |
1 | <?xml version="1.0"?> |
2 | <!--*-nxml-*--> | |
3a54a157 ZJS |
3 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
4 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | |
45ae1a05 | 5 | <!-- |
db9ecf05 | 6 | SPDX-License-Identifier: LGPL-2.1-or-later |
572eb058 | 7 | |
45ae1a05 LP |
8 | This is based on crypttab(5) from Fedora's initscripts package, which in |
9 | turn is based on Debian's version. | |
10 | ||
11 | The Red Hat version has been written by Miloslav Trmac <mitr@redhat.com>. | |
45ae1a05 | 12 | --> |
c2d54475 | 13 | <refentry id="crypttab" conditional='HAVE_LIBCRYPTSETUP' xmlns:xi="http://www.w3.org/2001/XInclude"> |
45ae1a05 | 14 | |
798d3a52 ZJS |
15 | <refentryinfo> |
16 | <title>crypttab</title> | |
17 | <productname>systemd</productname> | |
798d3a52 ZJS |
18 | </refentryinfo> |
19 | ||
20 | <refmeta> | |
21 | <refentrytitle>crypttab</refentrytitle> | |
22 | <manvolnum>5</manvolnum> | |
23 | </refmeta> | |
24 | ||
25 | <refnamediv> | |
26 | <refname>crypttab</refname> | |
27 | <refpurpose>Configuration for encrypted block devices</refpurpose> | |
28 | </refnamediv> | |
29 | ||
30 | <refsynopsisdiv> | |
31 | <para><filename>/etc/crypttab</filename></para> | |
32 | </refsynopsisdiv> | |
33 | ||
34 | <refsect1> | |
35 | <title>Description</title> | |
36 | ||
37 | <para>The <filename>/etc/crypttab</filename> file describes | |
38 | encrypted block devices that are set up during system boot.</para> | |
39 | ||
40 | <para>Empty lines and lines starting with the <literal>#</literal> | |
41 | character are ignored. Each of the remaining lines describes one | |
ed3657d5 | 42 | encrypted block device. Fields are delimited by white space.</para> |
b2a1a5c7 | 43 | |
6e41f4dd | 44 | <para>Each line is in the form<programlisting><replaceable>volume-name</replaceable> <replaceable>encrypted-device</replaceable> <replaceable>key-file</replaceable> <replaceable>options</replaceable></programlisting> |
b2a1a5c7 | 45 | The first two fields are mandatory, the remaining two are |
798d3a52 ZJS |
46 | optional.</para> |
47 | ||
48 | <para>Setting up encrypted block devices using this file supports | |
49 | three encryption modes: LUKS, TrueCrypt and plain. See | |
3ba3a79d | 50 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 ZJS |
51 | for more information about each mode. When no mode is specified in |
52 | the options field and the block device contains a LUKS signature, | |
53 | it is opened as a LUKS device; otherwise, it is assumed to be in | |
54 | raw dm-crypt (plain mode) format.</para> | |
55 | ||
96e9a9a4 LP |
56 | <para>The four fields of <filename>/etc/crypttab</filename> are defined as follows:</para> |
57 | ||
58 | <orderedlist> | |
59 | ||
60 | <listitem><para>The first field contains the name of the resulting volume with decrypted data; its | |
61 | block device is set up below <filename>/dev/mapper/</filename>.</para></listitem> | |
62 | ||
63 | <listitem><para>The second field contains a path to the underlying block | |
64 | device or file, or a specification of a block device via | |
65 | <literal>UUID=</literal> followed by the UUID.</para></listitem> | |
66 | ||
67 | <listitem><para>The third field specifies an absolute path to a file with the encryption | |
68 | key. Optionally, the path may be followed by <literal>:</literal> and an fstab device specification | |
69 | (e.g. starting with <literal>LABEL=</literal> or similar); in which case the path is taken relative to | |
70 | the device file system root. If the field is not present or is <literal>none</literal> or | |
71 | <literal>-</literal>, a key file named after the volume to unlock (i.e. the first column of the line), | |
72 | suffixed with <filename>.key</filename> is automatically loaded from the | |
73 | <filename>/etc/cryptsetup-keys.d/</filename> and <filename>/run/cryptsetup-keys.d/</filename> | |
74 | directories, if present. Otherwise, the password has to be manually entered during system boot. For | |
75 | swap encryption, <filename>/dev/urandom</filename> may be used as key file, resulting in a randomized | |
76 | key.</para> | |
77 | ||
78 | <para>If the specified key file path refers to an <constant>AF_UNIX</constant> stream socket in the | |
79 | file system, the key is acquired by connecting to the socket and reading it from the connection. This | |
80 | allows the implementation of a service to provide key information dynamically, at the moment when it is | |
81 | needed. For details see below.</para></listitem> | |
82 | ||
da115b93 | 83 | <listitem><para>The fourth field, if present, is a comma-delimited list of options. The supported |
96e9a9a4 LP |
84 | options are listed below.</para></listitem> |
85 | </orderedlist> | |
798d3a52 ZJS |
86 | |
87 | <variablelist class='fstab-options'> | |
88 | ||
798d3a52 ZJS |
89 | <varlistentry> |
90 | <term><option>cipher=</option></term> | |
91 | ||
b12bd993 ZJS |
92 | <listitem><para>Specifies the cipher to use. See <citerefentry |
93 | project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
94 | for possible values and the default value of this option. A cipher with unpredictable IV values, such | |
95 | as <literal>aes-cbc-essiv:sha256</literal>, is recommended. Embedded commas in the cipher | |
96 | specification need to be escaped by preceding them with a backslash, see example below.</para> | |
97 | </listitem> | |
798d3a52 ZJS |
98 | </varlistentry> |
99 | ||
ed3657d5 ZJS |
100 | <varlistentry> |
101 | <term><option>discard</option></term> | |
102 | ||
103 | <listitem><para>Allow discard requests to be passed through the encrypted block | |
104 | device. This improves performance on SSD storage but has security implications. | |
105 | </para></listitem> | |
106 | </varlistentry> | |
107 | ||
798d3a52 ZJS |
108 | <varlistentry> |
109 | <term><option>hash=</option></term> | |
110 | ||
111 | <listitem><para>Specifies the hash to use for password | |
112 | hashing. See | |
3ba3a79d | 113 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 ZJS |
114 | for possible values and the default value of this |
115 | option.</para></listitem> | |
116 | </varlistentry> | |
117 | ||
118 | <varlistentry> | |
119 | <term><option>header=</option></term> | |
120 | ||
121 | <listitem><para>Use a detached (separated) metadata device or | |
122 | file where the LUKS header is stored. This option is only | |
123 | relevant for LUKS devices. See | |
3ba3a79d | 124 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 | 125 | for possible values and the default value of this |
13445d97 OK |
126 | option.</para> |
127 | ||
128 | <para>Optionally, the path may be followed by <literal>:</literal> and an fstab device specification | |
129 | (e.g. starting with <literal>UUID=</literal> or similar); in which case, the path is relative to the | |
130 | device file system root. The device gets mounted automatically for LUKS device activation duration only. | |
131 | </para></listitem> | |
798d3a52 ZJS |
132 | </varlistentry> |
133 | ||
134 | <varlistentry> | |
135 | <term><option>keyfile-offset=</option></term> | |
136 | ||
137 | <listitem><para>Specifies the number of bytes to skip at the | |
138 | start of the key file. See | |
3ba3a79d | 139 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 ZJS |
140 | for possible values and the default value of this |
141 | option.</para></listitem> | |
142 | </varlistentry> | |
143 | ||
144 | <varlistentry> | |
145 | <term><option>keyfile-size=</option></term> | |
146 | ||
147 | <listitem><para>Specifies the maximum number of bytes to read | |
148 | from the key file. See | |
3ba3a79d | 149 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 ZJS |
150 | for possible values and the default value of this option. This |
151 | option is ignored in plain encryption mode, as the key file | |
152 | size is then given by the key size.</para></listitem> | |
153 | </varlistentry> | |
154 | ||
6e41f4dd LP |
155 | <varlistentry> |
156 | <term><option>keyfile-erase</option></term> | |
157 | ||
158 | <listitem><para>If enabled, the specified key file is erased after the volume is activated or when | |
159 | activation fails. This is in particular useful when the key file is only acquired transiently before | |
160 | activation (e.g. via a file in <filename>/run/</filename>, generated by a service running before | |
161 | activation), and shall be removed after use. Defaults to off.</para></listitem> | |
162 | </varlistentry> | |
163 | ||
798d3a52 ZJS |
164 | <varlistentry> |
165 | <term><option>key-slot=</option></term> | |
166 | ||
167 | <listitem><para>Specifies the key slot to compare the | |
168 | passphrase or key against. If the key slot does not match the | |
169 | given passphrase or key, but another would, the setup of the | |
170 | device will fail regardless. This option implies | |
171 | <option>luks</option>. See | |
3ba3a79d | 172 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 ZJS |
173 | for possible values. The default is to try all key slots in |
174 | sequential order.</para></listitem> | |
175 | </varlistentry> | |
176 | ||
4e133451 | 177 | <varlistentry> |
178 | <term><option>keyfile-timeout=</option></term> | |
179 | ||
180 | <listitem><para> Specifies the timeout for the device on | |
181 | which the key file resides and falls back to a password if | |
182 | it could not be mounted. See | |
183 | <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
184 | for key files on external devices. | |
185 | </para></listitem> | |
186 | </varlistentry> | |
187 | ||
798d3a52 ZJS |
188 | <varlistentry> |
189 | <term><option>luks</option></term> | |
190 | ||
191 | <listitem><para>Force LUKS mode. When this mode is used, the | |
192 | following options are ignored since they are provided by the | |
193 | LUKS header on the device: <option>cipher=</option>, | |
194 | <option>hash=</option>, | |
195 | <option>size=</option>.</para></listitem> | |
196 | </varlistentry> | |
197 | ||
6cc27c29 MF |
198 | <varlistentry> |
199 | <term><option>bitlk</option></term> | |
200 | ||
201 | <listitem><para>Decrypt Bitlocker drive. Encryption parameters | |
202 | are deduced by cryptsetup from Bitlocker header.</para></listitem> | |
203 | </varlistentry> | |
204 | ||
b001ad61 ZJS |
205 | <varlistentry> |
206 | <term><option>_netdev</option></term> | |
207 | ||
208 | <listitem><para>Marks this cryptsetup device as requiring network. It will be | |
209 | started after the network is available, similarly to | |
210 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
211 | units marked with <option>_netdev</option>. The service unit to set up this device | |
a0dd2097 | 212 | will be ordered between <filename>remote-fs-pre.target</filename> and |
b001ad61 ZJS |
213 | <filename>remote-cryptsetup.target</filename>, instead of |
214 | <filename>cryptsetup-pre.target</filename> and | |
288c2616 ZJS |
215 | <filename>cryptsetup.target</filename>.</para> |
216 | ||
217 | <para>Hint: if this device is used for a mount point that is specified in | |
218 | <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>, | |
219 | the <option>_netdev</option> option should also be used for the mount | |
220 | point. Otherwise, a dependency loop might be created where the mount point | |
221 | will be pulled in by <filename>local-fs.target</filename>, while the | |
222 | service to configure the network is usually only started <emphasis>after</emphasis> | |
223 | the local file system has been mounted.</para> | |
224 | </listitem> | |
b001ad61 ZJS |
225 | </varlistentry> |
226 | ||
798d3a52 ZJS |
227 | <varlistentry> |
228 | <term><option>noauto</option></term> | |
229 | ||
5d0e4851 ZJS |
230 | <listitem><para>This device will not be added to <filename>cryptsetup.target</filename>. |
231 | This means that it will not be automatically unlocked on boot, unless something else pulls | |
232 | it in. In particular, if the device is used for a mount point, it'll be unlocked | |
233 | automatically during boot, unless the mount point itself is also disabled with | |
234 | <option>noauto</option>.</para></listitem> | |
798d3a52 ZJS |
235 | </varlistentry> |
236 | ||
237 | <varlistentry> | |
238 | <term><option>nofail</option></term> | |
239 | ||
5d0e4851 | 240 | <listitem><para>This device will not be a hard dependency of |
7792d9cd | 241 | <filename>cryptsetup.target</filename>. It'll still be pulled in and started, but the system |
5d0e4851 ZJS |
242 | will not wait for the device to show up and be unlocked, and boot will not fail if this is |
243 | unsuccessful. Note that other units that depend on the unlocked device may still fail. In | |
7792d9cd AZ |
244 | particular, if the device is used for a mount point, the mount point itself also needs to |
245 | have the <option>nofail</option> option, or the boot will fail if the device is not unlocked | |
5d0e4851 | 246 | successfully.</para></listitem> |
798d3a52 ZJS |
247 | </varlistentry> |
248 | ||
ed3657d5 ZJS |
249 | <varlistentry> |
250 | <term><option>offset=</option></term> | |
251 | ||
252 | <listitem><para>Start offset in the backend device, in 512-byte sectors. This | |
253 | option is only relevant for plain devices.</para></listitem> | |
254 | </varlistentry> | |
255 | ||
798d3a52 ZJS |
256 | <varlistentry> |
257 | <term><option>plain</option></term> | |
258 | ||
259 | <listitem><para>Force plain encryption mode.</para></listitem> | |
260 | </varlistentry> | |
261 | ||
262 | <varlistentry> | |
263 | <term><option>read-only</option></term><term><option>readonly</option></term> | |
264 | ||
265 | <listitem><para>Set up the encrypted block device in read-only | |
266 | mode.</para></listitem> | |
267 | </varlistentry> | |
268 | ||
2c65512e YW |
269 | <varlistentry> |
270 | <term><option>same-cpu-crypt</option></term> | |
271 | ||
272 | <listitem><para>Perform encryption using the same cpu that IO was submitted on. The default is to use | |
273 | an unbound workqueue so that encryption work is automatically balanced between available CPUs.</para> | |
e9dd6984 | 274 | |
2c65512e YW |
275 | <para>This requires kernel 4.0 or newer.</para> |
276 | </listitem> | |
277 | </varlistentry> | |
278 | ||
279 | <varlistentry> | |
280 | <term><option>submit-from-crypt-cpus</option></term> | |
281 | ||
282 | <listitem><para>Disable offloading writes to a separate thread after encryption. There are some | |
e9dd6984 ZJS |
283 | situations where offloading write requests from the encryption threads to a dedicated thread degrades |
284 | performance significantly. The default is to offload write requests to a dedicated thread because it | |
285 | benefits the CFQ scheduler to have writes submitted using the same context.</para> | |
286 | ||
2c65512e YW |
287 | <para>This requires kernel 4.0 or newer.</para> |
288 | </listitem> | |
289 | </varlistentry> | |
290 | ||
ed3657d5 ZJS |
291 | <varlistentry> |
292 | <term><option>skip=</option></term> | |
293 | ||
294 | <listitem><para>How many 512-byte sectors of the encrypted data to skip at the | |
295 | beginning. This is different from the <option>offset=</option> option with respect | |
296 | to the sector numbers used in initialization vector (IV) calculation. Using | |
297 | <option>offset=</option> will shift the IV calculation by the same negative | |
298 | amount. Hence, if <option>offset=<replaceable>n</replaceable></option> is given, | |
299 | sector <replaceable>n</replaceable> will get a sector number of 0 for the IV | |
300 | calculation. Using <option>skip=</option> causes sector | |
301 | <replaceable>n</replaceable> to also be the first sector of the mapped device, but | |
302 | with its number for IV generation being <replaceable>n</replaceable>.</para> | |
303 | ||
304 | <para>This option is only relevant for plain devices.</para> | |
305 | </listitem> | |
306 | </varlistentry> | |
307 | ||
798d3a52 ZJS |
308 | <varlistentry> |
309 | <term><option>size=</option></term> | |
310 | ||
311 | <listitem><para>Specifies the key size in bits. See | |
3ba3a79d | 312 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 ZJS |
313 | for possible values and the default value of this |
314 | option.</para></listitem> | |
315 | </varlistentry> | |
316 | ||
a9fc6406 DJL |
317 | <varlistentry> |
318 | <term><option>sector-size=</option></term> | |
319 | ||
320 | <listitem><para>Specifies the sector size in bytes. See | |
321 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
322 | for possible values and the default value of this | |
323 | option.</para></listitem> | |
324 | </varlistentry> | |
325 | ||
798d3a52 ZJS |
326 | <varlistentry> |
327 | <term><option>swap</option></term> | |
328 | ||
329 | <listitem><para>The encrypted block device will be used as a | |
330 | swap device, and will be formatted accordingly after setting | |
331 | up the encrypted block device, with | |
332 | <citerefentry project='man-pages'><refentrytitle>mkswap</refentrytitle><manvolnum>8</manvolnum></citerefentry>. | |
333 | This option implies <option>plain</option>.</para> | |
334 | ||
335 | <para>WARNING: Using the <option>swap</option> option will | |
336 | destroy the contents of the named partition during every boot, | |
337 | so make sure the underlying block device is specified | |
338 | correctly.</para></listitem> | |
339 | </varlistentry> | |
340 | ||
341 | <varlistentry> | |
342 | <term><option>tcrypt</option></term> | |
343 | ||
344 | <listitem><para>Use TrueCrypt encryption mode. When this mode | |
345 | is used, the following options are ignored since they are | |
346 | provided by the TrueCrypt header on the device or do not | |
347 | apply: | |
348 | <option>cipher=</option>, | |
349 | <option>hash=</option>, | |
350 | <option>keyfile-offset=</option>, | |
351 | <option>keyfile-size=</option>, | |
352 | <option>size=</option>.</para> | |
353 | ||
354 | <para>When this mode is used, the passphrase is read from the | |
355 | key file given in the third field. Only the first line of this | |
356 | file is read, excluding the new line character.</para> | |
357 | ||
358 | <para>Note that the TrueCrypt format uses both passphrase and | |
359 | key files to derive a password for the volume. Therefore, the | |
360 | passphrase and all key files need to be provided. Use | |
361 | <option>tcrypt-keyfile=</option> to provide the absolute path | |
362 | to all key files. When using an empty passphrase in | |
363 | combination with one or more key files, use | |
364 | <literal>/dev/null</literal> as the password file in the third | |
365 | field.</para></listitem> | |
366 | </varlistentry> | |
367 | ||
368 | <varlistentry> | |
369 | <term><option>tcrypt-hidden</option></term> | |
370 | ||
371 | <listitem><para>Use the hidden TrueCrypt volume. This option | |
372 | implies <option>tcrypt</option>.</para> | |
373 | ||
374 | <para>This will map the hidden volume that is inside of the | |
375 | volume provided in the second field. Please note that there is | |
376 | no protection for the hidden volume if the outer volume is | |
377 | mounted instead. See | |
3ba3a79d | 378 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
798d3a52 ZJS |
379 | for more information on this limitation.</para></listitem> |
380 | </varlistentry> | |
381 | ||
382 | <varlistentry> | |
383 | <term><option>tcrypt-keyfile=</option></term> | |
384 | ||
385 | <listitem><para>Specifies the absolute path to a key file to | |
386 | use for a TrueCrypt volume. This implies | |
387 | <option>tcrypt</option> and can be used more than once to | |
388 | provide several key files.</para> | |
389 | ||
390 | <para>See the entry for <option>tcrypt</option> on the | |
391 | behavior of the passphrase and key files when using TrueCrypt | |
392 | encryption mode.</para></listitem> | |
393 | </varlistentry> | |
394 | ||
395 | <varlistentry> | |
396 | <term><option>tcrypt-system</option></term> | |
397 | ||
398 | <listitem><para>Use TrueCrypt in system encryption mode. This | |
399 | option implies <option>tcrypt</option>.</para></listitem> | |
400 | </varlistentry> | |
401 | ||
52028838 GH |
402 | <varlistentry> |
403 | <term><option>tcrypt-veracrypt</option></term> | |
404 | ||
405 | <listitem><para>Check for a VeraCrypt volume. VeraCrypt is a fork of | |
406 | TrueCrypt that is mostly compatible, but uses different, stronger key | |
407 | derivation algorithms that cannot be detected without this flag. | |
408 | Enabling this option could substantially slow down unlocking, because | |
409 | VeraCrypt's key derivation takes much longer than TrueCrypt's. This | |
410 | option implies <option>tcrypt</option>.</para></listitem> | |
411 | </varlistentry> | |
412 | ||
798d3a52 ZJS |
413 | <varlistentry> |
414 | <term><option>timeout=</option></term> | |
415 | ||
416 | <listitem><para>Specifies the timeout for querying for a | |
417 | password. If no unit is specified, seconds is used. Supported | |
418 | units are s, ms, us, min, h, d. A timeout of 0 waits | |
419 | indefinitely (which is the default).</para></listitem> | |
420 | </varlistentry> | |
421 | ||
798d3a52 | 422 | <varlistentry> |
53ac130b | 423 | <term><option>tmp=</option></term> |
798d3a52 | 424 | |
53ac130b LP |
425 | <listitem><para>The encrypted block device will be prepared for using it as |
426 | <filename>/tmp/</filename>; it will be formatted using <citerefentry | |
427 | project='man-pages'><refentrytitle>mkfs</refentrytitle><manvolnum>8</manvolnum></citerefentry>. Takes | |
428 | a file system type as argument, such as <literal>ext4</literal>, <literal>xfs</literal> or | |
429 | <literal>btrfs</literal>. If no argument is specified defaults to <literal>ext4</literal>. This | |
430 | option implies <option>plain</option>.</para> | |
798d3a52 | 431 | |
53ac130b LP |
432 | <para>WARNING: Using the <option>tmp</option> option will destroy the contents of the named partition |
433 | during every boot, so make sure the underlying block device is specified correctly.</para></listitem> | |
798d3a52 ZJS |
434 | </varlistentry> |
435 | ||
436 | <varlistentry> | |
437 | <term><option>tries=</option></term> | |
438 | ||
439 | <listitem><para>Specifies the maximum number of times the user | |
440 | is queried for a password. The default is 3. If set to 0, the | |
441 | user is queried for a password indefinitely.</para></listitem> | |
442 | </varlistentry> | |
443 | ||
444 | <varlistentry> | |
445 | <term><option>verify</option></term> | |
446 | ||
c2d54475 LP |
447 | <listitem><para>If the encryption password is read from console, it has to be entered twice to |
448 | prevent typos.</para></listitem> | |
449 | </varlistentry> | |
450 | ||
451 | <varlistentry> | |
452 | <term><option>pkcs11-uri=</option></term> | |
453 | ||
454 | <listitem><para>Takes a <ulink url="https://tools.ietf.org/html/rfc7512">RFC7512 PKCS#11 URI</ulink> | |
455 | pointing to a private RSA key which is used to decrypt the key specified in the third column of the | |
456 | line. This is useful for unlocking encrypted volumes through security tokens or smartcards. See below | |
457 | for an example how to set up this mechanism for unlocking a LUKS volume with a YubiKey security | |
458 | token. The specified URI can refer directly to a private RSA key stored on a token or alternatively | |
2ccf0ff6 LP |
459 | just to a slot or token, in which case a search for a suitable private RSA key will be performed. In |
460 | this case if multiple suitable objects are found the token is refused. The key configured in the | |
461 | third column is passed as is to RSA decryption. The resulting decrypted key is then base64 encoded | |
462 | before it is used to unlock the LUKS volume.</para></listitem> | |
798d3a52 ZJS |
463 | </varlistentry> |
464 | ||
6e41f4dd LP |
465 | <varlistentry> |
466 | <term><option>try-empty-password=</option></term> | |
467 | ||
468 | <listitem><para>Takes a boolean argument. If enabled, right before asking the user for a password it | |
469 | is first attempted to unlock the volume with an empty password. This is useful for systems that are | |
470 | initialized with an encrypted volume with only an empty password set, which shall be replaced with a | |
471 | suitable password during first boot, but after activation.</para></listitem> | |
472 | </varlistentry> | |
473 | ||
ed3657d5 ZJS |
474 | <varlistentry> |
475 | <term><option>x-systemd.device-timeout=</option></term> | |
476 | ||
477 | <listitem><para>Specifies how long systemd should wait for a device to show up | |
478 | before giving up on the entry. The argument is a time in seconds or explicitly | |
479 | specified units of | |
480 | <literal>s</literal>, | |
481 | <literal>min</literal>, | |
482 | <literal>h</literal>, | |
483 | <literal>ms</literal>. | |
484 | </para></listitem> | |
485 | </varlistentry> | |
486 | ||
1dc85eff FB |
487 | <varlistentry> |
488 | <term><option>x-initrd.attach</option></term> | |
489 | ||
490 | <listitem><para>Setup this encrypted block device in the initramfs, similarly to | |
491 | <citerefentry><refentrytitle>systemd.mount</refentrytitle><manvolnum>5</manvolnum></citerefentry> | |
492 | units marked with <option>x-initrd.mount</option>.</para> | |
493 | ||
494 | <para>Although it's not necessary to mark the mount entry for the root file system with | |
495 | <option>x-initrd.mount</option>, <option>x-initrd.attach</option> is still recommended with | |
496 | the encrypted block device containing the root file system as otherwise systemd will | |
497 | attempt to detach the device during the regular system shutdown while it's still in | |
498 | use. With this option the device will still be detached but later after the root file | |
499 | system is unmounted.</para> | |
500 | ||
501 | <para>All other encrypted block devices that contain file systems mounted in the initramfs | |
502 | should use this option.</para> | |
503 | </listitem> | |
504 | </varlistentry> | |
505 | ||
798d3a52 ZJS |
506 | </variablelist> |
507 | ||
508 | <para>At early boot and when the system manager configuration is | |
509 | reloaded, this file is translated into native systemd units by | |
510 | <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>.</para> | |
511 | </refsect1> | |
512 | ||
96e9a9a4 LP |
513 | <refsect1> |
514 | <title><constant>AF_UNIX</constant> Key Files</title> | |
515 | ||
516 | <para>If the key file path (as specified in the third column of <filename>/etc/crypttab</filename> | |
517 | entries, see above) refers to an <constant>AF_UNIX</constant> stream socket in the file system, the key | |
518 | is acquired by connecting to the socket and reading the key from the connection. The connection is made | |
519 | from an <constant>AF_UNIX</constant> socket name in the abstract namespace, see <citerefentry | |
520 | project='man-pages'><refentrytitle>unix</refentrytitle><manvolnum>7</manvolnum></citerefentry> for | |
521 | details. The source socket name is chosen according the following format:</para> | |
522 | ||
523 | <programlisting><constant>NUL</constant> <replaceable>RANDOM</replaceable> <literal>/cryptsetup/</literal> <replaceable>VOLUME</replaceable></programlisting> | |
524 | ||
525 | <para>In other words: a <constant>NUL</constant> byte (as required for abstract namespace sockets), | |
526 | followed by a random string (consisting of alphabenumeric characters only), followed by the literal | |
527 | string <literal>/cryptsetup/</literal>, followed by the name of the volume to acquire they key | |
528 | for. Example (for a volume <literal>myvol</literal>):</para> | |
529 | ||
530 | <example><programlisting>\0d7067f78d9827418/cryptsetup/myvol</programlisting></example> | |
531 | ||
532 | <para>Services listening on the <constant>AF_UNIX</constant> stream socket may query the source socket | |
533 | name with <citerefentry | |
534 | project='man-pages'><refentrytitle>getpeername</refentrytitle><manvolnum>2</manvolnum></citerefentry>, | |
535 | and use it to determine which key to send, allowing a single listening socket to serve keys for a | |
536 | multitude of volumes. If the PKCS#11 logic is used (see below) the socket source name is picked in | |
537 | identical fashion, except that the literal string <literal>/cryptsetup-pkcs11/</literal> is used. This is | |
538 | done so that services providing key material know that not a secret key is requested but an encrypted key | |
539 | that will be decrypted via the PKCS#11 logic to acquire the final secret key.</para> | |
540 | </refsect1> | |
798d3a52 | 541 | <refsect1> |
c2d54475 | 542 | <title>Examples</title> |
798d3a52 ZJS |
543 | <example> |
544 | <title>/etc/crypttab example</title> | |
b12bd993 ZJS |
545 | <para>Set up four encrypted block devices. One using LUKS for normal storage, another one for usage as |
546 | a swap device and two TrueCrypt volumes. For the fourth device, the option string is interpreted as two | |
547 | options <literal>cipher=xchacha12,aes-adiantum-plain64</literal>, | |
548 | <literal>keyfile-timeout=10s</literal>.</para> | |
798d3a52 ZJS |
549 | |
550 | <programlisting>luks UUID=2505567a-9e27-4efe-a4d5-15ad146c258b | |
551 | swap /dev/sda7 /dev/urandom swap | |
8cf3ca80 | 552 | truecrypt /dev/sda2 /etc/container_password tcrypt |
4e133451 | 553 | hidden /mnt/tc_hidden /dev/null tcrypt-hidden,tcrypt-keyfile=/etc/keyfile |
b12bd993 ZJS |
554 | external /dev/sda3 keyfile:LABEL=keydev keyfile-timeout=10s,cipher=xchacha12\,aes-adiantum-plain64 |
555 | </programlisting> | |
798d3a52 | 556 | </example> |
c2d54475 LP |
557 | |
558 | <example> | |
559 | <title>Yubikey-based Volume Unlocking Example</title> | |
560 | ||
561 | <para>The PKCS#11 logic allows hooking up any compatible security token that is capable of storing RSA | |
2ccf0ff6 | 562 | decryption keys. Here's an example how to set up a Yubikey security token for this purpose, using |
e9dd6984 ZJS |
563 | <citerefentry project='debian'><refentrytitle>ykmap</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
564 | from the yubikey-manager project:</para> | |
c2d54475 LP |
565 | |
566 | <programlisting><xi:include href="yubikey-crypttab.sh" parse="text" /></programlisting> | |
567 | ||
568 | <para>A few notes on the above:</para> | |
569 | ||
570 | <itemizedlist> | |
c2d54475 LP |
571 | <listitem><para>We use RSA2048, which is the longest key size current Yubikeys support</para></listitem> |
572 | <listitem><para>LUKS key size must be shorter than 2048bit due to RSA padding, hence we use 128 bytes</para></listitem> | |
573 | <listitem><para>We use Yubikey key slot 9d, since that's apparently the keyslot to use for decryption purposes, | |
574 | <ulink url="https://developers.yubico.com/PIV/Introduction/Certificate_slots.html">see | |
575 | documentation</ulink>.</para></listitem> | |
576 | </itemizedlist> | |
577 | ||
578 | </example> | |
798d3a52 ZJS |
579 | </refsect1> |
580 | ||
581 | <refsect1> | |
582 | <title>See Also</title> | |
583 | <para> | |
584 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
585 | <citerefentry><refentrytitle>systemd-cryptsetup@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>, | |
586 | <citerefentry><refentrytitle>systemd-cryptsetup-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>, | |
288c2616 | 587 | <citerefentry project='man-pages'><refentrytitle>fstab</refentrytitle><manvolnum>5</manvolnum></citerefentry>, |
3ba3a79d | 588 | <citerefentry project='die-net'><refentrytitle>cryptsetup</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
798d3a52 ZJS |
589 | <citerefentry project='man-pages'><refentrytitle>mkswap</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
590 | <citerefentry project='man-pages'><refentrytitle>mke2fs</refentrytitle><manvolnum>8</manvolnum></citerefentry> | |
591 | </para> | |
592 | </refsect1> | |
45ae1a05 LP |
593 | |
594 | </refentry> |