Skip to content

Instantly share code, notes, and snippets.

@manishrjain
Last active January 26, 2016 21:57
Show Gist options
  • Save manishrjain/336589df211428290041 to your computer and use it in GitHub Desktop.
Save manishrjain/336589df211428290041 to your computer and use it in GitHub Desktop.
GPG on Linux

To search for keys in keyserver

gpg --search-keys 'email@id.com'

To list keys

gpg --list-keys

Export secret key

gpg --export-secret-keys KEYID --armor

To import private key

gpg --allow-secret-key-import --import gpg_private.key

To encrypt file

gpg -e -r YOUR_EMAIL_ID filename

Trust a key

gpg --edit-key EMAIL_ID Then run trust, respond to question, then quit.

Ensure passphrase isn't asked repeatedly

In ~/.gnupg/gpg.conf, ensure it has use-agent option turned on. Also, potentially keyserver-options auto-key-retrieve. Then, create ~/.gnupg/gpg-agent.conf, and add these: default-cache-ttl 86400 max-cache-ttl 86400 Then, re-run gpg-agent, like so: eval $(gpg-agent --daemon)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment