Last active
June 21, 2022 19:56
-
-
Save Luis-Licea/b63bbd079288b6327bd119bf0bcd1277 to your computer and use it in GitHub Desktop.
Export and import GPG key pairs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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