'\" t
.\"     Title: cryptsetup-lukschangekey
.\"    Author: [see the "AUTHOR(S)" section]
.\" Generator: Asciidoctor 2.0.18
.\"      Date: 2023-12-18
.\"    Manual: Maintenance Commands
.\"    Source: cryptsetup 2.6.1
.\"  Language: English
.\"
.TH "CRYPTSETUP\-LUKSCHANGEKEY" "8" "2023-12-18" "cryptsetup 2.6.1" "Maintenance Commands"
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.ss \n[.ss] 0
.nh
.ad l
.de URL
\fI\\$2\fP <\\$1>\\$3
..
.als MTO URL
.if \n[.g] \{\
.  mso www.tmac
.  am URL
.    ad l
.  .
.  am MTO
.    ad l
.  .
.  LINKSTYLE blue R < >
.\}
.SH "NAME"
cryptsetup-luksChangeKey \- change an existing passphrase
.SH "SYNOPSIS"
.sp
\fBcryptsetup \fIluksChangeKey\fP [<options>] <device> [<new key file>]\fP
.SH "DESCRIPTION"
.sp
Changes an existing passphrase. The passphrase to be changed must be
supplied interactively or via \-\-key\-file. The new passphrase can be
supplied interactively or in a file given as the positional argument.
.sp
If a key\-slot is specified (via \-\-key\-slot), the passphrase for that
key\-slot must be given and the new passphrase will overwrite the
specified key\-slot. If no key\-slot is specified and there is still a
free key\-slot, then the new passphrase will be put into a free key\-slot
before the key\-slot containing the old passphrase is purged. If there is
no free key\-slot, then the key\-slot with the old passphrase is
overwritten directly.
.sp
\fBWARNING:\fP If a key\-slot is overwritten, a media failure during this
operation can cause the overwrite to fail after the old passphrase has
been wiped and make the LUKS container inaccessible.
.sp
\fBNOTE:\fP some parameters are effective only if used with LUKS2 format
that supports per\-keyslot parameters. For LUKS1, PBKDF type and hash
algorithm is always the same for all keyslots.
.sp
\fB<options>\fP can be [\-\-key\-file, \-\-keyfile\-offset, \-\-keyfile\-size,
\-\-new\-keyfile\-offset, \-\-iter\-time, \-\-pbkdf, \-\-pbkdf\-force\-iterations,
\-\-pbkdf\-memory, \-\-pbkdf\-parallel, \-\-new\-keyfile\-size, \-\-key\-slot,
\-\-force\-password, \-\-hash, \-\-header, \-\-disable\-locks, \-\-type,
\-\-keyslot\-cipher, \-\-keyslot\-key\-size, \-\-timeout, \-\-verify\-passphrase].
.SH "OPTIONS"
.sp
\fB\-\-type <device\-type>\fP
.RS 4
Specifies required device type, for more info read \fIBASIC ACTIONS\fP section in \fBcryptsetup\fP(8).
.RE
.sp
\fB\-\-hash, \-h\fP \fI<hash\-spec>\fP
.RS 4
The specified hash is used for PBKDF2 and AF splitter.
.RE
.sp
\fB\-\-verify\-passphrase, \-y\fP
.RS 4
When interactively asking for a passphrase, ask for it twice and
complain if both inputs do not match.
Ignored on input from file or stdin.
.RE
.sp
\fB\-\-key\-file, \-d\fP \fIname\fP
.RS 4
Read the passphrase from file.
.sp
If the name given is "\-", then the passphrase will be read from stdin.
In this case, reading will not stop at newline characters.
.sp
The passphrase supplied via \-\-key\-file is always the passphrase for existing
keyslot requested by the command.
.sp
If you want to set a new passphrase via key file, you have to use a
positional argument or parameter \-\-new\-keyfile.
.sp
See section \fINOTES ON PASSPHRASE PROCESSING\fP in \fBcryptsetup\fP(8) for more information.
.RE
.sp
\fB\-\-keyfile\-offset\fP \fIvalue\fP
.RS 4
Skip \fIvalue\fP bytes at the beginning of the key file.
.RE
.sp
\fB\-\-keyfile\-size, \-l\fP \fIvalue\fP
.RS 4
Read a maximum of \fIvalue\fP bytes from the key file. The default is to
read the whole file up to the compiled\-in maximum that can be queried
with \-\-help. Supplying more data than the compiled\-in maximum aborts
the operation.
.sp
This option is useful to cut trailing newlines, for example. If
\-\-keyfile\-offset is also given, the size count starts after the offset.
.RE
.sp
\fB\-\-new\-keyfile\-offset\fP \fIvalue\fP
.RS 4
Skip \fIvalue\fP bytes at the start when adding a new passphrase from key
file.
.RE
.sp
\fB\-\-new\-keyfile\-size\fP \fIvalue\fP
.RS 4
Read a maximum of \fIvalue\fP bytes when adding a new passphrase from key
file. The default is to read the whole file up to
the compiled\-in maximum length that can be queried with \-\-help.
Supplying more than the compiled in maximum aborts the operation. When
\-\-new\-keyfile\-offset is also given, reading starts after the offset.
.RE
.sp
\fB\-\-key\-slot, \-S <0\-N>\fP
.RS 4
For LUKS operations that add key material, this option allows you to
specify which key slot is selected for the new key.
.sp
The maximum number of key slots depends on the LUKS version. LUKS1 can have up
to 8 key slots. LUKS2 can have up to 32 key slots based on key slot area
size and key size, but a valid key slot ID can always be between 0 and
31 for LUKS2.
.RE
.sp
\fB\-\-pbkdf <PBKDF spec>\fP
.RS 4
Set Password\-Based Key Derivation Function (PBKDF) algorithm for LUKS
keyslot. The PBKDF can be: \fIpbkdf2\fP (for PBKDF2 according to RFC2898),
\fIargon2i\fP for Argon2i or \fIargon2id\fP for Argon2id (see
.URL "https://www.cryptolux.org/index.php/Argon2" "Argon2" ""
for more info).
.sp
For LUKS1, only PBKDF2 is accepted (no need to use this option). The
default PBKDF for LUKS2 is set during compilation time and is available
in \fIcryptsetup \-\-help\fP output.
.sp
A PBKDF is used for increasing dictionary and brute\-force attack cost
for keyslot passwords. The parameters can be time, memory and parallel
cost.
.sp
For PBKDF2, only time cost (number of iterations) applies. For
Argon2i/id, there is also memory cost (memory required during the
process of key derivation) and parallel cost (number of threads that run
in parallel during the key derivation.
.sp
Note that increasing memory cost also increases time, so the final
parameter values are measured by a benchmark. The benchmark tries to
find iteration time (\fI\-\-iter\-time\fP) with required memory cost
\fI\-\-pbkdf\-memory\fP. If it is not possible, the memory cost is decreased as
well. The parallel cost \fI\-\-pbkdf\-parallel\fP is constant and is checked
against available CPU cores.
.sp
You can see all PBKDF parameters for particular LUKS2 keyslot with
\fBcryptsetup\-luksDump\fP(8) command.
.sp
\fBNOTE:\fP If you do not want to use benchmark and want to specify all
parameters directly, use \fI\-\-pbkdf\-force\-iterations\fP with
\fI\-\-pbkdf\-memory\fP and \fI\-\-pbkdf\-parallel\fP. This will override the values
without benchmarking. Note it can cause extremely long unlocking time.
Use only in specific cases, for example, if you know that the formatted
device will be used on some small embedded system.
.sp
\fBMINIMAL AND MAXIMAL PBKDF COSTS:\fP For \fBPBKDF2\fP, the minimum iteration
count is 1000 and maximum is 4294967295 (maximum for 32bit unsigned
integer). Memory and parallel costs are unused for PBKDF2. For \fBArgon2i\fP
and \fBArgon2id\fP, minimum iteration count (CPU cost) is 4 and maximum is
4294967295 (maximum for 32bit unsigned integer). Minimum memory cost is
32 KiB and maximum is 4 GiB. (Limited by addressable memory on some CPU
platforms.) If the memory cost parameter is benchmarked (not specified
by a parameter) it is always in range from 64 MiB to 1 GiB. The parallel
cost minimum is 1 and maximum 4 (if enough CPUs cores are available,
otherwise it is decreased).
.RE
.sp
\fB\-\-iter\-time, \-i <number of milliseconds>\fP
.RS 4
The number of milliseconds to spend with PBKDF passphrase processing.
Specifying 0 as parameter selects the compiled\-in default.
.RE
.sp
\fB\-\-pbkdf\-memory <number>\fP
.RS 4
Set the memory cost for PBKDF (for Argon2i/id the number represents
kilobytes). Note that it is maximal value, PBKDF benchmark or
available physical memory can decrease it. This option is not
available for PBKDF2.
.RE
.sp
\fB\-\-pbkdf\-parallel <number>\fP
.RS 4
Set the parallel cost for PBKDF (number of threads, up to 4). Note
that it is maximal value, it is decreased automatically if CPU online
count is lower. This option is not available for PBKDF2.
.RE
.sp
\fB\-\-pbkdf\-force\-iterations <num>\fP
.RS 4
Avoid PBKDF benchmark and set time cost (iterations) directly. It can
be used for LUKS/LUKS2 device only. See \fI\-\-pbkdf\fP option for more
info.
.RE
.sp
\fB\-\-timeout, \-t <number of seconds>\fP
.RS 4
The number of seconds to wait before timeout on passphrase input via
terminal. It is relevant every time a passphrase is asked.
It has no effect if used in conjunction with \-\-key\-file.
.sp
This option is useful when the system should not stall if the user
does not input a passphrase, e.g. during boot. The default is a value
of 0 seconds, which means to wait forever.
.RE
.sp
\fB\-\-header <device or file storing the LUKS header>\fP
.RS 4
Use a detached (separated) metadata device or file where the LUKS
header is stored. This option allows one to store ciphertext and LUKS
header on different devices.
.sp
For commands that change the LUKS header (e.g. \fIluksAddKey\fP),
specify the device or file with the LUKS header directly as the LUKS
device.
.RE
.sp
\fB\-\-force\-password\fP
.RS 4
Do not use password quality checking for new LUKS passwords.
.sp
This option is ignored if cryptsetup is built without password
quality checking support.
.sp
For more info about password quality check, see the manual page for
\fBpwquality.conf(5)\fP and \fBpasswdqc.conf(5)\fP.
.RE
.sp
\fB\-\-disable\-locks\fP
.RS 4
Disable lock protection for metadata on disk. This option is valid
only for LUKS2 and ignored for other formats.
.sp
\fBWARNING:\fP Do not use this option unless you run cryptsetup in a
restricted environment where locking is impossible to perform (where
/run directory cannot be used).
.RE
.sp
\fB\-\-keyslot\-cipher <cipher\-spec>\fP
.RS 4
This option can be used to set specific cipher encryption for the
LUKS2 keyslot area.
.RE
.sp
\fB\-\-keyslot\-key\-size <bits>\fP
.RS 4
This option can be used to set specific key size for the LUKS2 keyslot
area.
.RE
.sp
\fB\-\-batch\-mode, \-q\fP
.RS 4
Suppresses all confirmation questions. Use with care!
.sp
If the \-\-verify\-passphrase option is not specified, this option also
switches off the passphrase verification.
.RE
.sp
\fB\-\-debug or \-\-debug\-json\fP
.RS 4
Run in debug mode with full diagnostic logs. Debug output lines are
always prefixed by \fB#\fP.
.sp
If \-\-debug\-json is used, additional LUKS2 JSON data structures are printed.
.RE
.sp
\fB\-\-version, \-V\fP
.RS 4
Show the program version.
.RE
.sp
\fB\-\-usage\fP
.RS 4
Show short option help.
.RE
.sp
\fB\-\-help, \-?\fP
.RS 4
Show help text and default parameters.
.RE
.SH "REPORTING BUGS"
.sp
Report bugs at \c
.MTO "cryptsetup\(atlists.linux.dev" "\fBcryptsetup mailing list\fP"
or in \c
.URL "https://gitlab.com/cryptsetup/cryptsetup/\-/issues/new" "\fBIssues project section\fP" "."
.sp
Please attach output of the failed command with \-\-debug option added.
.SH "SEE ALSO"
.sp
.URL "https://gitlab.com/cryptsetup/cryptsetup/wikis/FrequentlyAskedQuestions" "\fBCryptsetup FAQ\fP" ""
.sp
\fBcryptsetup\fP(8), \fBintegritysetup\fP(8) and \fBveritysetup\fP(8)
.SH "CRYPTSETUP"
.sp
Part of \c
.URL "https://gitlab.com/cryptsetup/cryptsetup/" "\fBcryptsetup project\fP" "."