simple utility to make frequent gpg (re)encryptions easier
https://github.com/dariusjonda/gpg-team.git
gpg-team is a very simplistic gpg wrapper that aids in encrypting and re-encrypting files based on a recipients list (recipients.txt).
The purpose of this script is to have a simple, gpg-based solution that can be used in small teams to handle sensitive information (like database connections or other credentials) for encrypting new files and (quickly) reencrypt already encrypted files in case the recipients change (e.g. new team member, permission changed)
make utility:
git clone https://github.com/dariusjonda/gpg-team.git
cd gpg-team
make clean install
gpg-team should now be installed in ~/.local/bin/gpg-team
cd gpg-team to get into repo directory. recipients.txt file in the main project directory containing thegpg-team -e recipients.txt file
Note: after successful encryption you will be asked whether to keep the plaintext file or not. Please make sure to delete plaintext files containing credentials in order to prevent exploits.
gpg-team -r recipients.txt file.gpg
gpg-team -a recipients.txt
Note: Only do this if you are sure that every file needs to be reencrypted!
gpg --full-generate-key
gpg --generate-key
for identification purposes you need to enter your name and email address.
Please use your real name / email address to make it easier to identify you for encrypting data.
gpg --list-secret-keys
--armor flag to have it in an ASCII-armored format (unencoded) to be able to also copy & paste the contents in case we need to:
gpg --export --armor your-email-address > ~/my-name_public-key.asc
gpg --list-keys).
You can import public keys using the following command:
gpg --import name-of-public-key.asc
--encrypt (short -e) and --recipient (short -r) flags:
gpg --encrypt --recipient email-or-name-of-recipient file-to-encrypt
You can also skip the recipient flag which will prompt you after entering the command.
--decrypt (short -d) flag:
gpg --decrypt file-to-decrypt.gpg
This will output the content in the terminal. If you want to store it in a file, just write it to another file:
gpg --decrypt file-to-decrypt.gpg > decrypted-filename.txt
gpg --list-secret-keys
secret_key.gpg you can use any filename you want
gpg --export-secret-keys your-email-address > ~/secret_key.gpg
/nfs/shared_drive/ (you can use that directory as well)
mv ~/secret_key.gpg /nfs/shared_drive/
the secret_key.gpg should now be stored under /nfs/shared_drive/. Either confirm that with the ls command or user your explorer.
gpg --import /nfs/shared_drive/secret_key.gpg
doing so will prompt pinentry to enter your GPG password. If the password was entered correctly, you will get the notification that the import was successfull and you should be able to view the secret key in your gpg keychain typing:
gpg --list-secret-keys
if you can see the gpg secret key in your keychain, proceed further. Otherwise go back and repeat the previous steps.
DO NOT FORGET TO DELETE YOUR SECRET_KEY THAT YOU STORED ON THE NETWORK DRIVE if you haven't done so already:
rm /nfs/shared_drive/secret_key.gpg
gpg --edit-key your-email-address
`
this will open a GPG prompt. Type trust -> 5 -> y -> save` to trust it ultimately and save your changes. If done correctly this should close the GPG prompt.