Search code examples
linuxbashgnupg

How To Change password/passphrase prompt text of GPG


in GPG while we are doing encryption

 gpg --cipher-algo AES256 --symmetric ./.abcd.csv

It open a prompt

Enter Passphrase

Can we change that too

Enter Passphrase for xyz:

enter image description here


Solution

  • The gpg PIN entry is handled by an external program or device, so there is no universal mean to control the prompt of a PIN, unless you force gpg into batch mode, and force PIN entry to loop back to the caller script, so you have full control of it.

    Note that this is of questionable security, because while taking control of the pin entry, you are also responsible for all the security, and a shell script is the least secure environment to handle secret data like a PIN.

    Here it is how you would control the PIN prompt.
    (Know the security concerns before using this):

    read -r -s -p 'Enter Passphrase for xyz: ' secret
    gpg \
      --cipher-algo AES256 \
      --pinentry-mode loopback \
      --batch \
      --passphrase "$secret" \
      --symmetric \
      ./.abcd.csv
    printf '\n'