If you're getting this message when encrypting files with a GnuPG—the GNU Pretty Good Privacy (PGP) package—you can mark your key as trusted (if that's the case). This often happens when you copy a trusted key from one machine to another.
Here's what I was getting before 'trusting' my own key.
gpg: <KEY_ID>: There is no assurance this key belongs to the named user
It is NOT certain that the key belongs to the person named
in the user ID. If you *really* know what you are doing,
you may answer the next question with yes.
Use this key anyway? (y/N) y
Every time, I'd have to answer y
to complete the encryption process.
I learned how to skip this step from this StackOverflow post.
gpg --edit-key <KEY_ID>
gpg › trust
Then you set the degree to which you trust the specified key.
1 = I don't know or won't say
2 = I do NOT trust
3 = I trust marginally
4 = I trust fully
5 = I trust ultimately
m = back to the main menu
I selected 5 as this is a key I created for myself.
Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y
Confirm, then quit.
gpg › quit
Now you can use your GPG key without confirm every operation.
openssl genrsa -out private.pem 4096
openssl rsa -in private.pem -out public.pem -outform PEM -pubout
openssl rsautl -encrypt -inkey public.pem -pubin -in file.txt -out file.ssl
openssl rsautl -decrypt -inkey private.pem -in file.ssl -out decrypted.txt
gpg --full-generate-key
(1) RSA and RSA
4096
(at least 4096 to stay safe)0
(key does not expire)y
Your Name Here
your@email.com
Optionally a comment
O
(to confirm)For reference, Here's more info from GitHub.
gpg --list-keys
gpg --list-secret-keys --keyid-format LONG
# First, remove the private key
gpg --delete-secret-key key-id
# Then, remove the public key
gpg --delete-key key-id
gpg --output file.gpg --encrypt --recipient mundowarezweb@gmail.com file.txt
gpg --output file.txt --decrypt file.gpg
From https://www.gnupg.org/gph/en/manual/x56.html.
In binary format (inconvenient to be public on the web or sent via email).
gpg --output nono.gpg --export mundowarezweb@gmail.com
In plain-text format.
gpg --armor --export mundowarezweb@gmail.com
In plain-text format, saved to a file.
gpg --armor --output nonos-key.gpg --export --recipient mundowarezweb@gmail.com
gpg --armor --export --recipient mundowarezweb@gmail.com > nonos-key.gpg
You may want to transfer the private key you use to decrypt your files to another machine. Let's see how.
First, you must ensure the key is installed on your machine.
List the keys you have to get the name of the key you want to export.
gpg --list-secret-keys
From the output above, the name is ``.
gpg --export-secret-key NAME > ~/Desktop/my-secret-key.asc
Copy that key to another machine.
Then import it.
gpg --import my-secret-key.asc
gpg -o file.txt.gpg -e -r your@email.com file.txt
Note that the email provided needs to match that in your public GPG key.
gpg -o "file.txt" -d "file.txt.gpg"
Note that the email provided needs to match that in your private GPG key.
If you don't have the secret key required to decrypt a file, you'll get the following message.
gpg: public key decryption failed: No secret key
gpg: decryption failed: No secret key
You can change the password you use to unlock your GPG private key.
gpg --edit-key KEY-ID
passwd
save