Skip to content

Instantly share code, notes, and snippets.

@Luis-Licea
Last active June 21, 2022 19:56
Show Gist options
  • Save Luis-Licea/b63bbd079288b6327bd119bf0bcd1277 to your computer and use it in GitHub Desktop.
Save Luis-Licea/b63bbd079288b6327bd119bf0bcd1277 to your computer and use it in GitHub Desktop.
Export and import GPG key pairs.
#!/usr/bin/env bash
# If there is only one argument:
if [ $# -eq 1 ] ; then
# Export the private key with the specified argument.
gpg --export-secret-keys --armor "$1" > "$1-private-key.asc"
# Export the public key with the specified argument.
gpg --export --armor "$1" > "$1-public-key.asc"
else
echo "Enter the name or email associated to the key pair."
fi
#!/usr/bin/env bash
# If there is only one argument:
if [ $# -eq 1 ] ; then
# Import the private key with the specified parameter.
gpg --import "$1-private-key.asc"
# Import the public key with the specified parameter.
gpg --import "$1-public-key.asc"
# Set the trust level for the imported public key.
gpg --edit-key "$1" trust quit
else
echo "Enter the name or email associated to the key pair."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment