I am looking for a bash script which input is the old and the new password for changing password of a *.gpg file.
I encrypted a txt file with command
gpg -c. System create a
file.txt.gpg. How can I change the passphrase that I created before?
You cannot change the passphrase, but you can decrypt and reencrypt:
gpg --decrypt file.txt.gpg | (gpg -c > tmp.gpg && mv tmp.gpg file.txt.gpg)
You shouldn't directly redirect to your encrypted file (it still needs to be decrypted) and the
&& make sure the
mv is not executed unless the encryption succeeded.
The above will prompt you once for your decryption password and then twice for the encryption.