NITROCLI(1) | General Commands Manual | NITROCLI(1) |
nitrocli - access Nitrokey devices
nitrocli [-m|--model pro|storage] [-v|--verbose] [-V|--version] command [arguments]
nitrocli provides access to Nitrokey devices. It supports the Nitrokey Pro and the Nitrokey Storage. It can be used to access the encrypted volume, the one-time password generator, and the password safe.
This command requires the admin PIN. To avoid accidental calls of this command, the user has to enter the PIN even if it has been cached.
The Nitrokey Storage comes with a storage area. This area is comprised of an unencrypted region and an encrypted one of fixed sizes, each made available to the user in the form of block devices. The encrypted region can optionally further be overlayed with up to four hidden volumes. Because of this overlay (which is required to achieve plausible deniability of the existence of hidden volumes), the burden of ensuring that data on the encrypted volume does not overlap with data on one of the hidden volumes is on the user.
The Nitrokey Pro and the Nitrokey Storage support the generation of one-time passwords using the HOTP algorithm according to RFC 4226 or the TOTP algorithm according to RFC 6238. The required data – a name and the secret – is stored in slots. Currently, the Nitrokey devices provide three HOTP slots and 15 TOTP slots. The slots are numbered per algorithm starting at zero.
The TOTP algorithm is a modified version of the HOTP algorithm that also uses the current time. Therefore, the Nitrokey clock must be synchronized with the clock of the application that requests the one-time password.
The --format option specifies the format of the secret. If it is set to ascii, each character of the given secret is interpreted as the ASCII code of one byte. If it is set to base32, the secret is interpreted as a base32 string according to RFC 4648. If it is set to hex, every two characters are interpreted as the hexadecimal value of one byte. The default value is hex.
algorithm is the OTP algorithm to use. Possible values are hotp for the HOTP algorithm according to RFC 4226 and totp for the TOTP algorithm according to RFC 6238 (default). digits is the number of digits the one-time password should have. Allowed values are 6 and 8 (default: 6). counter is the initial counter if the HOTP algorithm is used (default: 0). time window is the time window used with TOTP in seconds (default: 30).
Nitrokey devices have four configuration settings: the numlock, capslock and scrollock keys can be mapped to an HOTP slot, and OTP generation can be set to require the user PIN.
With the --numlock, --capslock and --scrollock options, the respective bindings can be set. slot is the number of the HOTP slot to bind the key to. If --no-numlock, --no-capslock or --no-scrollock is set, the respective binding is disabled. The two corresponding options are mutually exclusive.
If --otp-pin is set, the user PIN will be required to generate one-time passwords using the otp get command. If --no-otp-pin is set, OTP generation can be performed without PIN. These two options are mutually exclusive.
The Nitrokey Pro and the Nitrokey Storage provide a password safe (PWS) with 20 slots. In each of these slots you can store a name, a login, and a password. The PWS is not encrypted, but it is protected with the user PIN by the firmware. Once the PWS is unlocked by one of the commands listed below, it can be accessed without authentication. You can use the lock command to lock the password safe.
The fields are printed together with a label. Use the --quiet option to suppress the labels and to only output the values stored in the PWS slot.
Nitrokey devices have two PINs: the user PIN and the admin PIN. The user PIN must have at least six, the admin PIN at least eight characters. The user PIN is required for commands such as otp get (depending on the configuration) and for all pws commands. The admin PIN is usually required to change the device configuration.
Each PIN has a retry counter that is decreased with every wrong PIN entry and reset if the PIN was entered correctly. The initial retry counter is three. If the retry counter for the user PIN is zero, you can use the pin unblock command to unblock and reset the user PIN. If the retry counter for the admin PIN is zero, you have to perform a factory reset using the reset command or gpg(1). Use the status command to check the retry counters.
The program honors a set of environment variables that can be used to suppress interactive PIN entry through pinentry(1). The following variables are recognized:
Create a hidden volume in the first available slot, starting at
half the size of the encrypted volume (i.e., 50%) and stretching all the way
to its end (100%):
$ nitrocli storage hidden create 0 50 100
Configure a one-time password slot with a hexadecimal secret
representation:
$ nitrocli otp set 0 test-rfc4226 3132333435363738393031323334353637383930
--algorithm hotp
$ nitrocli otp set 1 test-foobar 666F6F626172 --algorithm hotp
$ nitrocli otp set 0 test-rfc6238 3132333435363738393031323334353637383930
--algorithm totp --digits 8
Configure a one-time password slot with an ASCII secret
representation:
$ nitrocli otp set 0 test-rfc4226 12345678901234567890 --format ascii
--algorithm hotp
$ nitrocli otp set 1 test-foobar foobar --format ascii --algorithm
hotp
$ nitrocli otp set 0 test-rfc6238 12345678901234567890 --format ascii
--algorithm totp --digits 8
Configure a one-time password slot with a base32 secret
representation:
$ nitrocli otp set 0 test-rfc4226 gezdgnbvgy3tqojqgezdgnbvgy3tqojq
--format base32 --algorithm hotp
$ nitrocli otp set 1 test-foobar mzxw6ytboi====== --format base32
--algorithm hotp
$ nitrocli otp set 0 test-rfc6238 gezdgnbvgy3tqojqgezdgnbvgy3tqojq
--format base32 --algorithm totp --digits 8
Generate a one-time password:
$ nitrocli otp get 0 --algorithm hotp
755224
$ nitrocli otp get 0 --algorithm totp --time 1234567890
89005924
Clear a one-time password slot:
$ nitrocli otp clear 0 --algorithm hotp
Query the configuration:
$ nitrocli config get
Config:
numlock binding: not set
capslock binding: not set
scrollock binding: not set
require user PIN for OTP: true
Change the configuration:
$ nitrocli config set --otp-pin
Configure a PWS slot:
$ nitrocli pws set 0 example.org john.doe passw0rd
Get the data from a slot:
$ nitrocli pws get 0
name: example.org
login: john.doe
password: passw0rd
Copy the password to the clipboard (requires xclip(1)).
$ nitrocli pws get 0 --password --quiet | xclip -in
Query the PWS slots:
$ nitrocli pws status
slot name
0 example.org
2019-05-26 |