GPG basic commands
- March 12th, 2015
- Write comment
Export your public key:
gpg –armor -o filename.asc –export localemailaddress
Generate key:
gpg –gen-key
Generate key with more options:
gpg –no-default-keyring –keyring $PWD/.gpg/jgz-keyring –secret-keyring $PWD/.gpg/jgz-secring –trustdb-name $PWD/.gpg/jgz-trustdb –no-random-seed-file –gen-key
Delete private keyring:
gpg –delete-secret-key user # Either email or Real Name in quotes
Delete pub key from keyring:
gpg –delete-key user # Either email or Real Name in quotes
Import public key:
gpg –import publickeyfile.asc
Decrypt a file:
gpg -o filename –decrypt filename.gpg
Note: I have found that if you use su to become the account that encrypted the file, you may need to do the following to allow other accounts access to your current tty:
This worked on a CentOS7 server:
chmod o+rw $(tty)
Encrypt a file:
gpg –output filename.gpg –encrypt –recipient recipeientemailaddress filename # recipientemailaddress is the email address used for a public previously imported.
Edit/trust key:
gpg –edit-key 12345678
gpg> trust
Check an existing key fingerprint:
gpg –fingerprint emailaddress