xref: /freebsd-src/sys/contrib/openzfs/man/man8/zfs-load-key.8 (revision eda14cbc264d6969b02f2b1994cef11148e914f1)
1*eda14cbcSMatt Macy.\"
2*eda14cbcSMatt Macy.\" CDDL HEADER START
3*eda14cbcSMatt Macy.\"
4*eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the
5*eda14cbcSMatt Macy.\" Common Development and Distribution License (the "License").
6*eda14cbcSMatt Macy.\" You may not use this file except in compliance with the License.
7*eda14cbcSMatt Macy.\"
8*eda14cbcSMatt Macy.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*eda14cbcSMatt Macy.\" or http://www.opensolaris.org/os/licensing.
10*eda14cbcSMatt Macy.\" See the License for the specific language governing permissions
11*eda14cbcSMatt Macy.\" and limitations under the License.
12*eda14cbcSMatt Macy.\"
13*eda14cbcSMatt Macy.\" When distributing Covered Code, include this CDDL HEADER in each
14*eda14cbcSMatt Macy.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*eda14cbcSMatt Macy.\" If applicable, add the following below this CDDL HEADER, with the
16*eda14cbcSMatt Macy.\" fields enclosed by brackets "[]" replaced with your own identifying
17*eda14cbcSMatt Macy.\" information: Portions Copyright [yyyy] [name of copyright owner]
18*eda14cbcSMatt Macy.\"
19*eda14cbcSMatt Macy.\" CDDL HEADER END
20*eda14cbcSMatt Macy.\"
21*eda14cbcSMatt Macy.\"
22*eda14cbcSMatt Macy.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
23*eda14cbcSMatt Macy.\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
24*eda14cbcSMatt Macy.\" Copyright (c) 2011, 2019 by Delphix. All rights reserved.
25*eda14cbcSMatt Macy.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
26*eda14cbcSMatt Macy.\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
27*eda14cbcSMatt Macy.\" Copyright (c) 2014 by Adam Stevko. All rights reserved.
28*eda14cbcSMatt Macy.\" Copyright (c) 2014 Integros [integros.com]
29*eda14cbcSMatt Macy.\" Copyright 2019 Richard Laager. All rights reserved.
30*eda14cbcSMatt Macy.\" Copyright 2018 Nexenta Systems, Inc.
31*eda14cbcSMatt Macy.\" Copyright 2019 Joyent, Inc.
32*eda14cbcSMatt Macy.\"
33*eda14cbcSMatt Macy.Dd January 13, 2020
34*eda14cbcSMatt Macy.Dt ZFS-LOAD-KEY 8
35*eda14cbcSMatt Macy.Os
36*eda14cbcSMatt Macy.Sh NAME
37*eda14cbcSMatt Macy.Nm zfs Ns Pf - Cm load-key
38*eda14cbcSMatt Macy.Nd Load, unload, or change the encryption key used to access a dataset.
39*eda14cbcSMatt Macy.Sh SYNOPSIS
40*eda14cbcSMatt Macy.Nm
41*eda14cbcSMatt Macy.Cm load-key
42*eda14cbcSMatt Macy.Op Fl nr
43*eda14cbcSMatt Macy.Op Fl L Ar keylocation
44*eda14cbcSMatt Macy.Fl a | Ar filesystem
45*eda14cbcSMatt Macy.Nm
46*eda14cbcSMatt Macy.Cm unload-key
47*eda14cbcSMatt Macy.Op Fl r
48*eda14cbcSMatt Macy.Fl a | Ar filesystem
49*eda14cbcSMatt Macy.Nm
50*eda14cbcSMatt Macy.Cm change-key
51*eda14cbcSMatt Macy.Op Fl l
52*eda14cbcSMatt Macy.Op Fl o Ar keylocation Ns = Ns Ar value
53*eda14cbcSMatt Macy.Op Fl o Ar keyformat Ns = Ns Ar value
54*eda14cbcSMatt Macy.Op Fl o Ar pbkdf2iters Ns = Ns Ar value
55*eda14cbcSMatt Macy.Ar filesystem
56*eda14cbcSMatt Macy.Nm
57*eda14cbcSMatt Macy.Cm change-key
58*eda14cbcSMatt Macy.Fl i
59*eda14cbcSMatt Macy.Op Fl l
60*eda14cbcSMatt Macy.Ar filesystem
61*eda14cbcSMatt Macy.Sh DESCRIPTION
62*eda14cbcSMatt Macy.Bl -tag -width ""
63*eda14cbcSMatt Macy.It Xo
64*eda14cbcSMatt Macy.Nm
65*eda14cbcSMatt Macy.Cm load-key
66*eda14cbcSMatt Macy.Op Fl nr
67*eda14cbcSMatt Macy.Op Fl L Ar keylocation
68*eda14cbcSMatt Macy.Fl a | Ar filesystem
69*eda14cbcSMatt Macy.Xc
70*eda14cbcSMatt MacyLoad the key for
71*eda14cbcSMatt Macy.Ar filesystem ,
72*eda14cbcSMatt Macyallowing it and all children that inherit the
73*eda14cbcSMatt Macy.Sy keylocation
74*eda14cbcSMatt Macyproperty to be accessed. The key will be expected in the format specified by the
75*eda14cbcSMatt Macy.Sy keyformat
76*eda14cbcSMatt Macyand location specified by the
77*eda14cbcSMatt Macy.Sy keylocation
78*eda14cbcSMatt Macyproperty. Note that if the
79*eda14cbcSMatt Macy.Sy keylocation
80*eda14cbcSMatt Macyis set to
81*eda14cbcSMatt Macy.Sy prompt
82*eda14cbcSMatt Macythe terminal will interactively wait for the key to be entered. Loading a key
83*eda14cbcSMatt Macywill not automatically mount the dataset. If that functionality is desired,
84*eda14cbcSMatt Macy.Nm zfs Cm mount Sy -l
85*eda14cbcSMatt Macywill ask for the key and mount the dataset
86*eda14cbcSMatt Macy.Po
87*eda14cbcSMatt Macysee
88*eda14cbcSMatt Macy.Xr zfs-mount 8
89*eda14cbcSMatt Macy.Pc .
90*eda14cbcSMatt MacyOnce the key is loaded the
91*eda14cbcSMatt Macy.Sy keystatus
92*eda14cbcSMatt Macyproperty will become
93*eda14cbcSMatt Macy.Sy available .
94*eda14cbcSMatt Macy.Bl -tag -width "-r"
95*eda14cbcSMatt Macy.It Fl r
96*eda14cbcSMatt MacyRecursively loads the keys for the specified filesystem and all descendent
97*eda14cbcSMatt Macyencryption roots.
98*eda14cbcSMatt Macy.It Fl a
99*eda14cbcSMatt MacyLoads the keys for all encryption roots in all imported pools.
100*eda14cbcSMatt Macy.It Fl n
101*eda14cbcSMatt MacyDo a dry-run
102*eda14cbcSMatt Macy.Pq Qq No-op
103*eda14cbcSMatt Macyload-key. This will cause zfs to simply check that the
104*eda14cbcSMatt Macyprovided key is correct. This command may be run even if the key is already
105*eda14cbcSMatt Macyloaded.
106*eda14cbcSMatt Macy.It Fl L Ar keylocation
107*eda14cbcSMatt MacyUse
108*eda14cbcSMatt Macy.Ar keylocation
109*eda14cbcSMatt Macyinstead of the
110*eda14cbcSMatt Macy.Sy keylocation
111*eda14cbcSMatt Macyproperty. This will not change the value of the property on the dataset. Note
112*eda14cbcSMatt Macythat if used with either
113*eda14cbcSMatt Macy.Fl r
114*eda14cbcSMatt Macyor
115*eda14cbcSMatt Macy.Fl a ,
116*eda14cbcSMatt Macy.Ar keylocation
117*eda14cbcSMatt Macymay only be given as
118*eda14cbcSMatt Macy.Sy prompt .
119*eda14cbcSMatt Macy.El
120*eda14cbcSMatt Macy.It Xo
121*eda14cbcSMatt Macy.Nm
122*eda14cbcSMatt Macy.Cm unload-key
123*eda14cbcSMatt Macy.Op Fl r
124*eda14cbcSMatt Macy.Fl a | Ar filesystem
125*eda14cbcSMatt Macy.Xc
126*eda14cbcSMatt MacyUnloads a key from ZFS, removing the ability to access the dataset and all of
127*eda14cbcSMatt Macyits children that inherit the
128*eda14cbcSMatt Macy.Sy keylocation
129*eda14cbcSMatt Macyproperty. This requires that the dataset is not currently open or mounted. Once
130*eda14cbcSMatt Macythe key is unloaded the
131*eda14cbcSMatt Macy.Sy keystatus
132*eda14cbcSMatt Macyproperty will become
133*eda14cbcSMatt Macy.Sy unavailable .
134*eda14cbcSMatt Macy.Bl -tag -width "-r"
135*eda14cbcSMatt Macy.It Fl r
136*eda14cbcSMatt MacyRecursively unloads the keys for the specified filesystem and all descendent
137*eda14cbcSMatt Macyencryption roots.
138*eda14cbcSMatt Macy.It Fl a
139*eda14cbcSMatt MacyUnloads the keys for all encryption roots in all imported pools.
140*eda14cbcSMatt Macy.El
141*eda14cbcSMatt Macy.It Xo
142*eda14cbcSMatt Macy.Nm
143*eda14cbcSMatt Macy.Cm change-key
144*eda14cbcSMatt Macy.Op Fl l
145*eda14cbcSMatt Macy.Op Fl o Ar keylocation Ns = Ns Ar value
146*eda14cbcSMatt Macy.Op Fl o Ar keyformat Ns = Ns Ar value
147*eda14cbcSMatt Macy.Op Fl o Ar pbkdf2iters Ns = Ns Ar value
148*eda14cbcSMatt Macy.Ar filesystem
149*eda14cbcSMatt Macy.Xc
150*eda14cbcSMatt Macy.It Xo
151*eda14cbcSMatt Macy.Nm
152*eda14cbcSMatt Macy.Cm change-key
153*eda14cbcSMatt Macy.Fl i
154*eda14cbcSMatt Macy.Op Fl l
155*eda14cbcSMatt Macy.Ar filesystem
156*eda14cbcSMatt Macy.Xc
157*eda14cbcSMatt MacyChanges the user's key (e.g. a passphrase) used to access a dataset. This
158*eda14cbcSMatt Macycommand requires that the existing key for the dataset is already loaded into
159*eda14cbcSMatt MacyZFS. This command may also be used to change the
160*eda14cbcSMatt Macy.Sy keylocation ,
161*eda14cbcSMatt Macy.Sy keyformat ,
162*eda14cbcSMatt Macyand
163*eda14cbcSMatt Macy.Sy pbkdf2iters
164*eda14cbcSMatt Macyproperties as needed. If the dataset was not previously an encryption root it
165*eda14cbcSMatt Macywill become one. Alternatively, the
166*eda14cbcSMatt Macy.Fl i
167*eda14cbcSMatt Macyflag may be provided to cause an encryption root to inherit the parent's key
168*eda14cbcSMatt Macyinstead.
169*eda14cbcSMatt Macy.Pp
170*eda14cbcSMatt MacyIf the user's key is compromised,
171*eda14cbcSMatt Macy.Nm zfs Cm change-key
172*eda14cbcSMatt Macydoes not necessarily protect existing or newly-written data from attack.
173*eda14cbcSMatt MacyNewly-written data will continue to be encrypted with the same master key as
174*eda14cbcSMatt Macythe existing data.  The master key is compromised if an attacker obtains a
175*eda14cbcSMatt Macyuser key and the corresponding wrapped master key. Currently,
176*eda14cbcSMatt Macy.Nm zfs Cm change-key
177*eda14cbcSMatt Macydoes not overwrite the previous wrapped master key on disk, so it is
178*eda14cbcSMatt Macyaccessible via forensic analysis for an indeterminate length of time.
179*eda14cbcSMatt Macy.Pp
180*eda14cbcSMatt MacyIn the event of a master key compromise, ideally the drives should be securely
181*eda14cbcSMatt Macyerased to remove all the old data (which is readable using the compromised
182*eda14cbcSMatt Macymaster key), a new pool created, and the data copied back. This can be
183*eda14cbcSMatt Macyapproximated in place by creating new datasets, copying the data
184*eda14cbcSMatt Macy(e.g. using
185*eda14cbcSMatt Macy.Nm zfs Cm send
186*eda14cbcSMatt Macy|
187*eda14cbcSMatt Macy.Nm zfs Cm recv Ns
188*eda14cbcSMatt Macy), and then clearing the free space with
189*eda14cbcSMatt Macy.Nm zpool Cm trim --secure
190*eda14cbcSMatt Macyif supported by your hardware, otherwise
191*eda14cbcSMatt Macy.Nm zpool Cm initialize Ns .
192*eda14cbcSMatt Macy.Bl -tag -width "-r"
193*eda14cbcSMatt Macy.It Fl l
194*eda14cbcSMatt MacyEnsures the key is loaded before attempting to change the key. This is
195*eda14cbcSMatt Macyeffectively equivalent to
196*eda14cbcSMatt Macy.Qq Nm zfs Cm load-key Ar filesystem ; Nm zfs Cm change-key Ar filesystem
197*eda14cbcSMatt Macy.It Fl o Ar property Ns = Ns Ar value
198*eda14cbcSMatt MacyAllows the user to set encryption key properties (
199*eda14cbcSMatt Macy.Sy keyformat ,
200*eda14cbcSMatt Macy.Sy keylocation ,
201*eda14cbcSMatt Macyand
202*eda14cbcSMatt Macy.Sy pbkdf2iters
203*eda14cbcSMatt Macy) while changing the key. This is the only way to alter
204*eda14cbcSMatt Macy.Sy keyformat
205*eda14cbcSMatt Macyand
206*eda14cbcSMatt Macy.Sy pbkdf2iters
207*eda14cbcSMatt Macyafter the dataset has been created.
208*eda14cbcSMatt Macy.It Fl i
209*eda14cbcSMatt MacyIndicates that zfs should make
210*eda14cbcSMatt Macy.Ar filesystem
211*eda14cbcSMatt Macyinherit the key of its parent. Note that this command can only be run on an
212*eda14cbcSMatt Macyencryption root that has an encrypted parent.
213*eda14cbcSMatt Macy.El
214*eda14cbcSMatt Macy.El
215*eda14cbcSMatt Macy.Ss Encryption
216*eda14cbcSMatt MacyEnabling the
217*eda14cbcSMatt Macy.Sy encryption
218*eda14cbcSMatt Macyfeature allows for the creation of encrypted filesystems and volumes.  ZFS
219*eda14cbcSMatt Macywill encrypt file and zvol data, file attributes, ACLs, permission bits,
220*eda14cbcSMatt Macydirectory listings, FUID mappings, and
221*eda14cbcSMatt Macy.Sy userused
222*eda14cbcSMatt Macy/
223*eda14cbcSMatt Macy.Sy groupused
224*eda14cbcSMatt Macydata.  ZFS will not encrypt metadata related to the pool structure, including
225*eda14cbcSMatt Macydataset and snapshot names, dataset hierarchy, properties, file size, file
226*eda14cbcSMatt Macyholes, and deduplication tables (though the deduplicated data itself is
227*eda14cbcSMatt Macyencrypted).
228*eda14cbcSMatt Macy.Pp
229*eda14cbcSMatt MacyKey rotation is managed by ZFS.  Changing the user's key (e.g. a passphrase)
230*eda14cbcSMatt Macydoes not require re-encrypting the entire dataset.  Datasets can be scrubbed,
231*eda14cbcSMatt Macyresilvered, renamed, and deleted without the encryption keys being loaded (see the
232*eda14cbcSMatt Macy.Nm zfs Cm load-key
233*eda14cbcSMatt Macysubcommand for more info on key loading).
234*eda14cbcSMatt Macy.Pp
235*eda14cbcSMatt MacyCreating an encrypted dataset requires specifying the
236*eda14cbcSMatt Macy.Sy encryption
237*eda14cbcSMatt Macyand
238*eda14cbcSMatt Macy.Sy keyformat
239*eda14cbcSMatt Macyproperties at creation time, along with an optional
240*eda14cbcSMatt Macy.Sy keylocation
241*eda14cbcSMatt Macyand
242*eda14cbcSMatt Macy.Sy pbkdf2iters .
243*eda14cbcSMatt MacyAfter entering an encryption key, the
244*eda14cbcSMatt Macycreated dataset will become an encryption root. Any descendant datasets will
245*eda14cbcSMatt Macyinherit their encryption key from the encryption root by default, meaning that
246*eda14cbcSMatt Macyloading, unloading, or changing the key for the encryption root will implicitly
247*eda14cbcSMatt Macydo the same for all inheriting datasets. If this inheritance is not desired,
248*eda14cbcSMatt Macysimply supply a
249*eda14cbcSMatt Macy.Sy keyformat
250*eda14cbcSMatt Macywhen creating the child dataset or use
251*eda14cbcSMatt Macy.Nm zfs Cm change-key
252*eda14cbcSMatt Macyto break an existing relationship, creating a new encryption root on the child.
253*eda14cbcSMatt MacyNote that the child's
254*eda14cbcSMatt Macy.Sy keyformat
255*eda14cbcSMatt Macymay match that of the parent while still creating a new encryption root, and
256*eda14cbcSMatt Macythat changing the
257*eda14cbcSMatt Macy.Sy encryption
258*eda14cbcSMatt Macyproperty alone does not create a new encryption root; this would simply use a
259*eda14cbcSMatt Macydifferent cipher suite with the same key as its encryption root. The one
260*eda14cbcSMatt Macyexception is that clones will always use their origin's encryption key.
261*eda14cbcSMatt MacyAs a result of this exception, some encryption-related properties (namely
262*eda14cbcSMatt Macy.Sy keystatus ,
263*eda14cbcSMatt Macy.Sy keyformat ,
264*eda14cbcSMatt Macy.Sy keylocation ,
265*eda14cbcSMatt Macyand
266*eda14cbcSMatt Macy.Sy pbkdf2iters )
267*eda14cbcSMatt Macydo not inherit like other ZFS properties and instead use the value determined
268*eda14cbcSMatt Macyby their encryption root. Encryption root inheritance can be tracked via the
269*eda14cbcSMatt Macyread-only
270*eda14cbcSMatt Macy.Sy encryptionroot
271*eda14cbcSMatt Macyproperty.
272*eda14cbcSMatt Macy.Pp
273*eda14cbcSMatt MacyEncryption changes the behavior of a few ZFS
274*eda14cbcSMatt Macyoperations. Encryption is applied after compression so compression ratios are
275*eda14cbcSMatt Macypreserved. Normally checksums in ZFS are 256 bits long, but for encrypted data
276*eda14cbcSMatt Macythe checksum is 128 bits of the user-chosen checksum and 128 bits of MAC from
277*eda14cbcSMatt Macythe encryption suite, which provides additional protection against maliciously
278*eda14cbcSMatt Macyaltered data. Deduplication is still possible with encryption enabled but for
279*eda14cbcSMatt Macysecurity, datasets will only dedup against themselves, their snapshots, and
280*eda14cbcSMatt Macytheir clones.
281*eda14cbcSMatt Macy.Pp
282*eda14cbcSMatt MacyThere are a few limitations on encrypted datasets. Encrypted data cannot be
283*eda14cbcSMatt Macyembedded via the
284*eda14cbcSMatt Macy.Sy embedded_data
285*eda14cbcSMatt Macyfeature. Encrypted datasets may not have
286*eda14cbcSMatt Macy.Sy copies Ns = Ns Em 3
287*eda14cbcSMatt Macysince the implementation stores some encryption metadata where the third copy
288*eda14cbcSMatt Macywould normally be. Since compression is applied before encryption datasets may
289*eda14cbcSMatt Macybe vulnerable to a CRIME-like attack if applications accessing the data allow
290*eda14cbcSMatt Macyfor it. Deduplication with encryption will leak information about which blocks
291*eda14cbcSMatt Macyare equivalent in a dataset and will incur an extra CPU cost per block written.
292*eda14cbcSMatt Macy.Sh SEE ALSO
293*eda14cbcSMatt Macy.Xr zfs-create 8 ,
294*eda14cbcSMatt Macy.Xr zfs-set 8 ,
295*eda14cbcSMatt Macy.Xr zfsprops 8
296