Public key (to lock/encrypt the message) and a Private key (to unlock/decrypt the message).
You need to send the public key to all your users so that they can encrypt sensitive messages that they want to send it to you.
Once you receive an encrypted message, you need to use your private key to decrypt it.
- Command to generate the key pair.
script -q -c "gpg --gen-key" /dev/null
- Command to list keys.
- export the key using following command.
input = User Key = "Vijaya User" (from above pgp generation key)
input = Key ID = This will get generated while creating the key.
Reference : https://linuxaria.com/howto/how-to-easily-encrypt-a-file-with-gpg-on-linux
pwd.txt will have the passphrase.
GPG allows you to bypass prompts with the --batch flag, so we can add that in to our command
--passphrase-fd 0 tells GnuPG to retrieve the passphrase from input into the current shel
Sample Script to Decrypt:
cat $PassPhrase | gpg --output $OutputFileName --batch --yes --passphrase-fd 0 $SourceFilePath
Sample Script to Enecrypt:
gpg --batch --yes --trust-model always -r $PublicKeyUser -o $OutFilePath -e $SourceFilePath
- import pgp key
Reference : https://linuxaria.com/howto/how-to-easily-encrypt-a-file-with-gpg-on-linux
- Sample gpg command to decrypt a file :
pwd.txt will have the passphrase.
GPG allows you to bypass prompts with the --batch flag, so we can add that in to our command
--passphrase-fd 0 tells GnuPG to retrieve the passphrase from input into the current shel
Sample Script to Decrypt:
cat $PassPhrase | gpg --output $OutputFileName --batch --yes --passphrase-fd 0 $SourceFilePath
Sample Script to Enecrypt:
gpg --batch --yes --trust-model always -r $PublicKeyUser -o $OutFilePath -e $SourceFilePath
No comments:
Post a Comment