⭕With Commandline
Instructions on importing your gpg keys from your device to your yubikey.
DANGER: Exporting keys to Yubikey will destroy the local key. Ensure a backup has been made before doing this (so original state can be restored). See Backup GPG Keys and Restore Original GPG State respectively.
Plug your yubikey into a usb slot on your device and run the command:
gpg --card-statusOnce you've confirmed that your Yubikey data is being read, type:
gpg --list-secret-keys --keyid-format=shortThis will print a list of your current keys.
sec rsa4096/531AF8AA 2022-11-14 [C]
516755A58447F4FE8D2AE8A3A6EFD06F531AF8AA
uid [ultimate] Aetherinox <johndoe@email.com>
ssb rsa4096/1705A11E 2022-11-14 [S]
ssb rsa4096/8E7130EA 2022-11-14 [E]
ssb rsa4096/2D4537E9 2022-11-14 [A]Note the ID 531AF8AA at the top of the list under sec. You will need to copy your own key ID and use it with the following command:
Console will now print out the keys associated to that master key id:
To move a key to your Yubikey; you need to select it and then transfer.
To select, we use the key command followed by the key number which is 1 2 or 3.
For example: type key 1 to select first subkey.
The console will place a * next to ssb. Typing key 1 again will deselect that key.
After you select the subkey and it shows a * to the right of the word ssb, type:
Since we're moving our signature subkey, we will select (1) Signature Key from the options:
You will be prompted for your passphrase.
Once that key is moved, type key 1 again to deselect the first key and remove the * asterisk from the front.
We will now execute:
List of keys will appear with the selection:
Transfer the subkey to your card:
Select the slot Encryption Key:
Deselect key 2 to remove the asterisk:
Select key 3:
List of keys will appear with the selection:
Start the transfer with:
Select the Authentication Key option:
After you've entered the requested passphrase, we will save all changes with:
You now have your subkeys transferred to your Yubikey.
To confirm all the keys are on your Yubikey, unplug your Yubikey for a few seconds, and then plug it back in. Open your Command Prompt / Powershell, and type:
You should see a list of information about your GPG interface of your Yubikey, and toward the bottom, you should also see a list of keys imported onto your Yubikey.
Last updated
Was this helpful?