age

/media/images/asymmetric-encryption-1939847046.png

age is a modern file encryption tool that can be used as a replacement for gpg. Unfortunately my particular use case isn't explicitly described in the examples. Here is how to encrypt a file with a password protected private key.

make a password protected key file:

age-keygen | age -p > sensitive.key

get the public key from this file:

age -d sensitive.key | age-keygen -y

encrypt to this public key:

age -r age13te9f7kd3x88e3lkaq5rf46hf6eeqhrp5x7e2j4z7j65gzv36sjqgqmv9a sensitive.plaintext > sensitive.age

decrypt using the password protected key file:

age -d -i sensitive.key sensitive.age > sensitive.plaintext

shred it when we're done:

shred -u /home/na/sensitive.plaintext

You could also do symmetric encryption, but this sort of two-factor authentication is slightly more secure against rubber hose cryptanalysis