Skip to content

Instantly share code, notes, and snippets.

@parj
Created May 19, 2019 10:56
Show Gist options
  • Save parj/aa6db77cd496bf85d08e97f552bef270 to your computer and use it in GitHub Desktop.
Save parj/aa6db77cd496bf85d08e97f552bef270 to your computer and use it in GitHub Desktop.
Decrypting gpg private key and importing gpg
#!/bin/bash
# Stop on error
set -e
main() {
decryptAndImportPrivateKeys
}
# From gist - https://gist.github.com/Bost/54291d824149f0c4157b40329fceb02c
tstp() {
date +"%Y-%m-%d %H:%M:%S,%3N"
}
# From gist - https://gist.github.com/Bost/54291d824149f0c4157b40329fceb02c
exeinf() {
echo "INFO " $(tstp) "$ "$@
}
# From gist - https://gist.github.com/Bost/54291d824149f0c4157b40329fceb02c
exeerr() {
echo "ERROR" $(tstp) "$ "$@
}
decryptAndImportPrivateKeys() {
exeinf "Unzipping archive"
unzip -o .travis/secret-private-key.zip -d .travis
exeinf "Extracting private gpg key"
openssl aes-256-cbc -d -in .travis/secret-private-key -out .travis/gpg-private-key.asc -k "${PRIVATE_KEY}"
exeinf "Importing gpg key"
gpg --batch --import .travis/gpg-private-key.asc
exeinf "List Keys"
gpg --list-secret-keys
gpg --list-public-keys
exeinf "Completed importing key"
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment