Skip to content

Instantly share code, notes, and snippets.

@osvalr
Last active March 1, 2017 02:45
Show Gist options
  • Save osvalr/c6a3c72b879abd236851e6fae82c6a15 to your computer and use it in GitHub Desktop.
Save osvalr/c6a3c72b879abd236851e6fae82c6a15 to your computer and use it in GitHub Desktop.
#!/bin/bash
# This gist is mainly for export and import your gpg keys in order to backup them individualy,
# use somewhere else or whatever you want to do.
# usage:
# (1) $ export_gpg my-email@theserver.org fname
# NOTE: it will create two files: fname-gpg.txt, fname-gpg.key
#
# (2) $ import_gpg fname
export_gpg(){
email=$1
filename=$2
gpg -a --export $email > ${filename}-gpg.key
gpg -a --export-secret-keys $email > ${filename}-gpg.key
gpg --export-ownertrust > ${filename}-gpg.txt
}
import_gpg(){
filename=$1
gpg --import ${filename}-gpg.key
gpg --import-ownertrust ${filename}-gpg.txt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment