1eda14cbcSMatt Macy.\" 2eda14cbcSMatt Macy.\" CDDL HEADER START 3eda14cbcSMatt Macy.\" 4eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the 5eda14cbcSMatt Macy.\" Common Development and Distribution License (the "License"). 6eda14cbcSMatt Macy.\" You may not use this file except in compliance with the License. 7eda14cbcSMatt Macy.\" 8eda14cbcSMatt Macy.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9271171e0SMartin Matuska.\" or https://opensource.org/licenses/CDDL-1.0. 10eda14cbcSMatt Macy.\" See the License for the specific language governing permissions 11eda14cbcSMatt Macy.\" and limitations under the License. 12eda14cbcSMatt Macy.\" 13eda14cbcSMatt Macy.\" When distributing Covered Code, include this CDDL HEADER in each 14eda14cbcSMatt Macy.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15eda14cbcSMatt Macy.\" If applicable, add the following below this CDDL HEADER, with the 16eda14cbcSMatt Macy.\" fields enclosed by brackets "[]" replaced with your own identifying 17eda14cbcSMatt Macy.\" information: Portions Copyright [yyyy] [name of copyright owner] 18eda14cbcSMatt Macy.\" 19eda14cbcSMatt Macy.\" CDDL HEADER END 20eda14cbcSMatt Macy.\" 21eda14cbcSMatt Macy.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved. 22eda14cbcSMatt Macy.\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org> 23eda14cbcSMatt Macy.\" Copyright (c) 2011, 2019 by Delphix. All rights reserved. 24eda14cbcSMatt Macy.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved. 25eda14cbcSMatt Macy.\" Copyright (c) 2014, Joyent, Inc. All rights reserved. 26eda14cbcSMatt Macy.\" Copyright (c) 2014 by Adam Stevko. All rights reserved. 27eda14cbcSMatt Macy.\" Copyright (c) 2014 Integros [integros.com] 28eda14cbcSMatt Macy.\" Copyright 2019 Richard Laager. All rights reserved. 29eda14cbcSMatt Macy.\" Copyright 2018 Nexenta Systems, Inc. 30eda14cbcSMatt Macy.\" Copyright 2019 Joyent, Inc. 31eda14cbcSMatt Macy.\" 32eda14cbcSMatt Macy.Dd January 13, 2020 33eda14cbcSMatt Macy.Dt ZFS-LOAD-KEY 8 34eda14cbcSMatt Macy.Os 3516038816SMartin Matuska. 36eda14cbcSMatt Macy.Sh NAME 377877fdebSMatt Macy.Nm zfs-load-key 3816038816SMartin Matuska.Nd load, unload, or change encryption key of ZFS dataset 39eda14cbcSMatt Macy.Sh SYNOPSIS 407877fdebSMatt Macy.Nm zfs 41eda14cbcSMatt Macy.Cm load-key 42eda14cbcSMatt Macy.Op Fl nr 43eda14cbcSMatt Macy.Op Fl L Ar keylocation 4416038816SMartin Matuska.Fl a Ns | Ns Ar filesystem 457877fdebSMatt Macy.Nm zfs 46eda14cbcSMatt Macy.Cm unload-key 47eda14cbcSMatt Macy.Op Fl r 4816038816SMartin Matuska.Fl a Ns | Ns Ar filesystem 497877fdebSMatt Macy.Nm zfs 50eda14cbcSMatt Macy.Cm change-key 51eda14cbcSMatt Macy.Op Fl l 52eda14cbcSMatt Macy.Op Fl o Ar keylocation Ns = Ns Ar value 53eda14cbcSMatt Macy.Op Fl o Ar keyformat Ns = Ns Ar value 54eda14cbcSMatt Macy.Op Fl o Ar pbkdf2iters Ns = Ns Ar value 55eda14cbcSMatt Macy.Ar filesystem 567877fdebSMatt Macy.Nm zfs 57eda14cbcSMatt Macy.Cm change-key 58eda14cbcSMatt Macy.Fl i 59eda14cbcSMatt Macy.Op Fl l 60eda14cbcSMatt Macy.Ar filesystem 6116038816SMartin Matuska. 62eda14cbcSMatt Macy.Sh DESCRIPTION 63eda14cbcSMatt Macy.Bl -tag -width "" 64eda14cbcSMatt Macy.It Xo 657877fdebSMatt Macy.Nm zfs 66eda14cbcSMatt Macy.Cm load-key 67eda14cbcSMatt Macy.Op Fl nr 68eda14cbcSMatt Macy.Op Fl L Ar keylocation 6916038816SMartin Matuska.Fl a Ns | Ns Ar filesystem 70eda14cbcSMatt Macy.Xc 71eda14cbcSMatt MacyLoad the key for 72eda14cbcSMatt Macy.Ar filesystem , 73eda14cbcSMatt Macyallowing it and all children that inherit the 74eda14cbcSMatt Macy.Sy keylocation 7516038816SMartin Matuskaproperty to be accessed. 7616038816SMartin MatuskaThe key will be expected in the format specified by the 77eda14cbcSMatt Macy.Sy keyformat 78eda14cbcSMatt Macyand location specified by the 79eda14cbcSMatt Macy.Sy keylocation 8016038816SMartin Matuskaproperty. 8116038816SMartin MatuskaNote that if the 82eda14cbcSMatt Macy.Sy keylocation 83eda14cbcSMatt Macyis set to 84eda14cbcSMatt Macy.Sy prompt 8516038816SMartin Matuskathe terminal will interactively wait for the key to be entered. 8616038816SMartin MatuskaLoading a key will not automatically mount the dataset. 8716038816SMartin MatuskaIf that functionality is desired, 8816038816SMartin Matuska.Nm zfs Cm mount Fl l 89eda14cbcSMatt Macywill ask for the key and mount the dataset 90eda14cbcSMatt Macy.Po 91eda14cbcSMatt Macysee 92eda14cbcSMatt Macy.Xr zfs-mount 8 93eda14cbcSMatt Macy.Pc . 94eda14cbcSMatt MacyOnce the key is loaded the 95eda14cbcSMatt Macy.Sy keystatus 96eda14cbcSMatt Macyproperty will become 97eda14cbcSMatt Macy.Sy available . 98eda14cbcSMatt Macy.Bl -tag -width "-r" 99eda14cbcSMatt Macy.It Fl r 100eda14cbcSMatt MacyRecursively loads the keys for the specified filesystem and all descendent 101eda14cbcSMatt Macyencryption roots. 102eda14cbcSMatt Macy.It Fl a 103eda14cbcSMatt MacyLoads the keys for all encryption roots in all imported pools. 104eda14cbcSMatt Macy.It Fl n 105eda14cbcSMatt MacyDo a dry-run 106eda14cbcSMatt Macy.Pq Qq No-op 10716038816SMartin Matuska.Cm load-key . 10816038816SMartin MatuskaThis will cause 10916038816SMartin Matuska.Nm zfs 11016038816SMartin Matuskato simply check that the provided key is correct. 11116038816SMartin MatuskaThis command may be run even if the key is already loaded. 112eda14cbcSMatt Macy.It Fl L Ar keylocation 113eda14cbcSMatt MacyUse 114eda14cbcSMatt Macy.Ar keylocation 115eda14cbcSMatt Macyinstead of the 116eda14cbcSMatt Macy.Sy keylocation 11716038816SMartin Matuskaproperty. 11816038816SMartin MatuskaThis will not change the value of the property on the dataset. 11916038816SMartin MatuskaNote that if used with either 120eda14cbcSMatt Macy.Fl r 121eda14cbcSMatt Macyor 122eda14cbcSMatt Macy.Fl a , 123eda14cbcSMatt Macy.Ar keylocation 124eda14cbcSMatt Macymay only be given as 125eda14cbcSMatt Macy.Sy prompt . 126eda14cbcSMatt Macy.El 127eda14cbcSMatt Macy.It Xo 1287877fdebSMatt Macy.Nm zfs 129eda14cbcSMatt Macy.Cm unload-key 130eda14cbcSMatt Macy.Op Fl r 13116038816SMartin Matuska.Fl a Ns | Ns Ar filesystem 132eda14cbcSMatt Macy.Xc 133eda14cbcSMatt MacyUnloads a key from ZFS, removing the ability to access the dataset and all of 134eda14cbcSMatt Macyits children that inherit the 135eda14cbcSMatt Macy.Sy keylocation 13616038816SMartin Matuskaproperty. 13716038816SMartin MatuskaThis requires that the dataset is not currently open or mounted. 13816038816SMartin MatuskaOnce the key is unloaded the 139eda14cbcSMatt Macy.Sy keystatus 140eda14cbcSMatt Macyproperty will become 141eda14cbcSMatt Macy.Sy unavailable . 142eda14cbcSMatt Macy.Bl -tag -width "-r" 143eda14cbcSMatt Macy.It Fl r 144eda14cbcSMatt MacyRecursively unloads the keys for the specified filesystem and all descendent 145eda14cbcSMatt Macyencryption roots. 146eda14cbcSMatt Macy.It Fl a 147eda14cbcSMatt MacyUnloads the keys for all encryption roots in all imported pools. 148eda14cbcSMatt Macy.El 149eda14cbcSMatt Macy.It Xo 1507877fdebSMatt Macy.Nm zfs 151eda14cbcSMatt Macy.Cm change-key 152eda14cbcSMatt Macy.Op Fl l 153eda14cbcSMatt Macy.Op Fl o Ar keylocation Ns = Ns Ar value 154eda14cbcSMatt Macy.Op Fl o Ar keyformat Ns = Ns Ar value 155eda14cbcSMatt Macy.Op Fl o Ar pbkdf2iters Ns = Ns Ar value 156eda14cbcSMatt Macy.Ar filesystem 157eda14cbcSMatt Macy.Xc 158eda14cbcSMatt Macy.It Xo 1597877fdebSMatt Macy.Nm zfs 160eda14cbcSMatt Macy.Cm change-key 161eda14cbcSMatt Macy.Fl i 162eda14cbcSMatt Macy.Op Fl l 163eda14cbcSMatt Macy.Ar filesystem 164eda14cbcSMatt Macy.Xc 16516038816SMartin MatuskaChanges the user's key (e.g. a passphrase) used to access a dataset. 16616038816SMartin MatuskaThis command requires that the existing key for the dataset is already loaded. 16716038816SMartin MatuskaThis command may also be used to change the 168eda14cbcSMatt Macy.Sy keylocation , 169eda14cbcSMatt Macy.Sy keyformat , 170eda14cbcSMatt Macyand 171eda14cbcSMatt Macy.Sy pbkdf2iters 17216038816SMartin Matuskaproperties as needed. 17316038816SMartin MatuskaIf the dataset was not previously an encryption root it will become one. 17416038816SMartin MatuskaAlternatively, the 175eda14cbcSMatt Macy.Fl i 176eda14cbcSMatt Macyflag may be provided to cause an encryption root to inherit the parent's key 177eda14cbcSMatt Macyinstead. 178eda14cbcSMatt Macy.Pp 179eda14cbcSMatt MacyIf the user's key is compromised, 180eda14cbcSMatt Macy.Nm zfs Cm change-key 181eda14cbcSMatt Macydoes not necessarily protect existing or newly-written data from attack. 182eda14cbcSMatt MacyNewly-written data will continue to be encrypted with the same master key as 18316038816SMartin Matuskathe existing data. 18416038816SMartin MatuskaThe master key is compromised if an attacker obtains a 18516038816SMartin Matuskauser key and the corresponding wrapped master key. 18616038816SMartin MatuskaCurrently, 187eda14cbcSMatt Macy.Nm zfs Cm change-key 188eda14cbcSMatt Macydoes not overwrite the previous wrapped master key on disk, so it is 189eda14cbcSMatt Macyaccessible via forensic analysis for an indeterminate length of time. 190eda14cbcSMatt Macy.Pp 191eda14cbcSMatt MacyIn the event of a master key compromise, ideally the drives should be securely 192eda14cbcSMatt Macyerased to remove all the old data (which is readable using the compromised 19316038816SMartin Matuskamaster key), a new pool created, and the data copied back. 19416038816SMartin MatuskaThis can be approximated in place by creating new datasets, copying the data 19516038816SMartin Matuska.Pq e.g. using Nm zfs Cm send | Nm zfs Cm recv , 19616038816SMartin Matuskaand then clearing the free space with 19716038816SMartin Matuska.Nm zpool Cm trim Fl -secure 198eda14cbcSMatt Macyif supported by your hardware, otherwise 19916038816SMartin Matuska.Nm zpool Cm initialize . 200eda14cbcSMatt Macy.Bl -tag -width "-r" 201eda14cbcSMatt Macy.It Fl l 20216038816SMartin MatuskaEnsures the key is loaded before attempting to change the key. 203e92ffd9bSMartin MatuskaThis is effectively equivalent to running 20416038816SMartin Matuska.Nm zfs Cm load-key Ar filesystem ; Nm zfs Cm change-key Ar filesystem 205eda14cbcSMatt Macy.It Fl o Ar property Ns = Ns Ar value 20616038816SMartin MatuskaAllows the user to set encryption key properties 20716038816SMartin Matuska.Pq Sy keyformat , keylocation , No and Sy pbkdf2iters 20816038816SMartin Matuskawhile changing the key. 20916038816SMartin MatuskaThis is the only way to alter 210eda14cbcSMatt Macy.Sy keyformat 211eda14cbcSMatt Macyand 212eda14cbcSMatt Macy.Sy pbkdf2iters 213eda14cbcSMatt Macyafter the dataset has been created. 214eda14cbcSMatt Macy.It Fl i 215eda14cbcSMatt MacyIndicates that zfs should make 216eda14cbcSMatt Macy.Ar filesystem 21716038816SMartin Matuskainherit the key of its parent. 21816038816SMartin MatuskaNote that this command can only be run on an encryption root 21916038816SMartin Matuskathat has an encrypted parent. 220eda14cbcSMatt Macy.El 221eda14cbcSMatt Macy.El 222eda14cbcSMatt Macy.Ss Encryption 223eda14cbcSMatt MacyEnabling the 224eda14cbcSMatt Macy.Sy encryption 22516038816SMartin Matuskafeature allows for the creation of encrypted filesystems and volumes. 22616038816SMartin MatuskaZFS will encrypt file and volume data, file attributes, ACLs, permission bits, 227eda14cbcSMatt Macydirectory listings, FUID mappings, and 22816038816SMartin Matuska.Sy userused Ns / Ns Sy groupused 22916038816SMartin Matuskadata. 23016038816SMartin MatuskaZFS will not encrypt metadata related to the pool structure, including 231eda14cbcSMatt Macydataset and snapshot names, dataset hierarchy, properties, file size, file 232eda14cbcSMatt Macyholes, and deduplication tables (though the deduplicated data itself is 233eda14cbcSMatt Macyencrypted). 234eda14cbcSMatt Macy.Pp 23516038816SMartin MatuskaKey rotation is managed by ZFS. 23616038816SMartin MatuskaChanging the user's key (e.g. a passphrase) 23716038816SMartin Matuskadoes not require re-encrypting the entire dataset. 23816038816SMartin MatuskaDatasets can be scrubbed, 239*bb2d13b6SMartin Matuskaresilvered, renamed, and deleted without the encryption keys being loaded (see 240*bb2d13b6SMartin Matuskathe 24116038816SMartin Matuska.Cm load-key 242eda14cbcSMatt Macysubcommand for more info on key loading). 243eda14cbcSMatt Macy.Pp 244eda14cbcSMatt MacyCreating an encrypted dataset requires specifying the 24516038816SMartin Matuska.Sy encryption No and Sy keyformat 246eda14cbcSMatt Macyproperties at creation time, along with an optional 24716038816SMartin Matuska.Sy keylocation No and Sy pbkdf2iters . 248eda14cbcSMatt MacyAfter entering an encryption key, the 24916038816SMartin Matuskacreated dataset will become an encryption root. 25016038816SMartin MatuskaAny descendant datasets will 251eda14cbcSMatt Macyinherit their encryption key from the encryption root by default, meaning that 252eda14cbcSMatt Macyloading, unloading, or changing the key for the encryption root will implicitly 25316038816SMartin Matuskado the same for all inheriting datasets. 25416038816SMartin MatuskaIf this inheritance is not desired, simply supply a 255eda14cbcSMatt Macy.Sy keyformat 256eda14cbcSMatt Macywhen creating the child dataset or use 257eda14cbcSMatt Macy.Nm zfs Cm change-key 258eda14cbcSMatt Macyto break an existing relationship, creating a new encryption root on the child. 259eda14cbcSMatt MacyNote that the child's 260eda14cbcSMatt Macy.Sy keyformat 261eda14cbcSMatt Macymay match that of the parent while still creating a new encryption root, and 262eda14cbcSMatt Macythat changing the 263eda14cbcSMatt Macy.Sy encryption 264eda14cbcSMatt Macyproperty alone does not create a new encryption root; this would simply use a 26516038816SMartin Matuskadifferent cipher suite with the same key as its encryption root. 26616038816SMartin MatuskaThe one exception is that clones will always use their origin's encryption key. 26716038816SMartin MatuskaAs a result of this exception, some encryption-related properties 26816038816SMartin Matuska.Pq namely Sy keystatus , keyformat , keylocation , No and Sy pbkdf2iters 269eda14cbcSMatt Macydo not inherit like other ZFS properties and instead use the value determined 27016038816SMartin Matuskaby their encryption root. 27116038816SMartin MatuskaEncryption root inheritance can be tracked via the read-only 272eda14cbcSMatt Macy.Sy encryptionroot 273eda14cbcSMatt Macyproperty. 274eda14cbcSMatt Macy.Pp 275eda14cbcSMatt MacyEncryption changes the behavior of a few ZFS 27616038816SMartin Matuskaoperations. 27716038816SMartin MatuskaEncryption is applied after compression so compression ratios are preserved. 27816038816SMartin MatuskaNormally checksums in ZFS are 256 bits long, but for encrypted data 279eda14cbcSMatt Macythe checksum is 128 bits of the user-chosen checksum and 128 bits of MAC from 280eda14cbcSMatt Macythe encryption suite, which provides additional protection against maliciously 28116038816SMartin Matuskaaltered data. 28216038816SMartin MatuskaDeduplication is still possible with encryption enabled but for security, 28316038816SMartin Matuskadatasets will only deduplicate against themselves, their snapshots, 28416038816SMartin Matuskaand their clones. 285eda14cbcSMatt Macy.Pp 28616038816SMartin MatuskaThere are a few limitations on encrypted datasets. 28716038816SMartin MatuskaEncrypted data cannot be embedded via the 288eda14cbcSMatt Macy.Sy embedded_data 28916038816SMartin Matuskafeature. 29016038816SMartin MatuskaEncrypted datasets may not have 291eda14cbcSMatt Macy.Sy copies Ns = Ns Em 3 292eda14cbcSMatt Macysince the implementation stores some encryption metadata where the third copy 29316038816SMartin Matuskawould normally be. 29416038816SMartin MatuskaSince compression is applied before encryption, datasets may 295*bb2d13b6SMartin Matuskabe vulnerable to a CRIME-like attack if applications accessing the data allow 296*bb2d13b6SMartin Matuskafor it. 29716038816SMartin MatuskaDeduplication with encryption will leak information about which blocks 298*bb2d13b6SMartin Matuskaare equivalent in a dataset and will incur an extra CPU cost for each block 299*bb2d13b6SMartin Matuskawritten. 30016038816SMartin Matuska. 301eda14cbcSMatt Macy.Sh SEE ALSO 3023ff01b23SMartin Matuska.Xr zfsprops 7 , 303eda14cbcSMatt Macy.Xr zfs-create 8 , 3043ff01b23SMartin Matuska.Xr zfs-set 8 305