Using pass.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export PASSWORD_STORE_DIR="$HOME/.password-store"
export backup_store_dir="/media/backup/.password-store"
pass init pgpKeyID
pass git init -b main
pass git config --bool --add pass.signcommits true
mkdir -p "$backup_store_dir"
cd "$backup_store_dir"
git init -b temp
cd "$PASSWORD_STORE_DIR"
pass git remote add backup "$backup_store_dir"
pass git push -u backup
cd "$backup_store_dir"
git switch main
git branch -d temp
1
pass insert --multiline my/file < /my/file.bin
Prompt for an otpauth URI.
1
pass otp insert library_access
Full URI with all parameters.
1
otpauth://totp/Falvey%20Library:john.doe@email.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=Falvey%20Library&algorithm=SHA1&digits=6&period=30
Only append the OTP secret key using defaults for other parameters.
1
pass otp append --secret --issuer FalveyLibrary --account john.doe@email.com library_access
Use your webcam to scan a QR code of the otpauth URI with zbar.
1
zbarcam -q --raw | pass otp insert totp-secret
Copy line to clipboard.
1
2
3
pass show my_account -c
pass show my_account -c2
pass otp my_account -c
Hardening hints in durable configuration files.
Encrypt the disk to prevent traces of PGP key backups.
Get other keys the password store is encrypted to from the keyserver.
1
gpg --recv-keys $(cat .gpg-id)
Verify, sign, and marginally trust at least three other keys.
1
2
3
4
gpg --with-fingerprint keyID # verify fingerprint out of band
gpg --sign-key keyID # sign
gpg --send-keys keyID # send signed key to keyserver
gpg --edit-key keyID # trust the key
1
2
trust # 3 , marginally
save
gpg --import pubkey.asc or gpg --receive-key keyIDgpg --fingerprint keyID out of bandgpg --sign-key keyIDgpg --send-keys keyIDpass init $(cat .gpg-id) keyIDGnuPG implements the OpenPGP standard. PGP key in modern usage means a key conforming to the OpenPGP standard.
1
2
3
4
5
# $HOME/.gnupg/gpg.conf
default-recipient-self
default-key keyID
keyid-format long
keyserver hkps://keyring.debian.org:443
Show current configuration for gpg components.
1
2
3
4
gpgconf
gpgconf -v --list-options gpg
gpgconf -v --list-options gpg-agent
gpgconf -v --list-options dirmngr
Show keys from file.
1
gpg --show-keys debian-keyring.gpg
Show secret keys with subkey fingerprints.
1
gpg --list-secret-keys --with-subkey-fingerprint mainKeyID
Key info details in the GPG repository git://git.gnupg.org/gnupg.git, GPG repository mirror.
pub - public primary keysub - public subkeysec - secret primary keyssb - secret subkey[E] - encrypt[S] - sign[C] - certify[A] - authentication[D] - disabledSuffixing the key ID or fingerprint with !, a specific subkey or the primary key can be targeted. By default GnuPG uses the latest key with the required capability.
Encrypt using symmetric encryption and do not cache the password. Test with clear results.
1
2
gpg --no-symkey-cache --symmetric file.txt
gpg --decrypt file.txt.gpg > decrypted_file.txt
1
2
3
gpg --full-generate-key
gpg --list-secret-keys
gpg --edit-key keyID
Add subkey, change key usage. Signing keys can be changed to authentication keys.
1
2
3
4
5
6
7
8
help
addkey
list
key 0 # select main key
change-usage # change usage of the main key
key 2 # select subkey
change-usage # change selected subkey
save
Replace user identity to change info, add another.
1
2
3
4
5
adduid
uid 1
deluid
adduid
save
It is good practice to create a key with subkeys for signing, encryption, authentication and remove signing capability from the main key, storing the main private key offline. This makes revocation easy.
Backup the secret keys. Optionally pipe to paperkey for a printable backup.
1
2
3
gpg --export-options backup --export-secret-keys mainKeyID > secretKeys.gpg
gpg --export-options backup --export-secret-keys mainKeyID! > mainSecretKey.gpg
gpg --export-options backup --export-secret-subkeys mainKeyID > secretSubKeys.gpg
Save backups on an offline device. Main secret certification key is rarely needed.
Optionally remove the main secret certification key from the system.
1
2
gpg --delete-secret-keys mainKeyID!
gpg --list-secret-keys mainKeyID
Missing key is marked '#'.
1
sec# ed25519/keyID
Restore the key, keeping trust info.
1
gpg --import-options 'restore keep-ownertrust' --import secretKeys.gpg
Transfer trust info over ssh. Export is better than copying trustdb.gpg.
1
gpg --export-ownertrust | ssh user@othermachine gpg --import-ownertrust
Get the ASCII armored public key, convert it to PGP format and restore a secret key from a paperkey.
1
2
3
4
5
wget <url> --output-document backup.export.public.keys.asc
gpg --dearmor < backup.export.public.keys.asc > public.dearmored.gpg
paperkey --pubring public.dearmored.gpg \
--secrets backup.export.secret.key.paperkey |\
gpg --import-options 'restore keep-ownertrust' --import -
1
gpg --edit-keys keyID
1
2
3
key compromisedSubKeyID
revkey
save
Upload the updated key to keyserver.
1
gpg --send-keys keyID
Export the public key as ASCII armored text, identifying the key with the user name. Easy to publish when keyserver usage is not an option.
1
gpg -a --export tester > tester.pub.asc
Hide the key ID of this user's key. This option helps to hide the receiver of the message and is a limited countermeasure against traffic analysis.
1
2
gpg --encrypt --multifile --hidden-recipient key3ID file.txt file.png
gpg --decrypt file.txt.gpg > file.txt_decrypted.txt
1
2
3
4
5
6
7
gpg: encrypted with ECDH key, ID 0000000000000000
gpg: anonymous recipient; trying secret key key1ID ...
gpg: ecdh failed in gcry_cipher_decrypt: Checksum error
gpg: anonymous recipient; trying secret key key2ID ...
gpg: ecdh failed in gcry_cipher_decrypt: Checksum error
gpg: anonymous recipient; trying secret key key3ID ...
gpg: okay, we are the anonymous recipient.
GnuPG's network access daemon configuration, client.
1
2
# $HOME/.gnupg/dirmngr.conf
keyserver hkps://keyring.debian.org:443
Hosting a Web Key Directory.
The future is elliptical-curve cryptography (ECC), which will bring a level of safety comparable to RSA-16384. Gnupg defaults to algorithms using it.
EdDSA - Edwards-Curve Digital Signature Algorithm
ed25519.
cv25519 is an encryption algorithm.