Search code examples
linuxbashgnupg

Bsign: read password from stdin


Good evening.

Is it possible for bsign to accept a password from stdin, not from a terminal?

Or, may be are there ways to alter password-entering program? I wish my script to auto-sign all my binaries before uploading them to a testing stand.


Solution

  • bsign knows -P flag which passes parameters to gpg.

    --passphrase-fd 0 will enable you to read the passphrase from stdin. Alternatively you could use --passphrase-file for reading it from a file or even --passphrase string for directly passing it.

    bsign -P '--passphrase-fd 0' ...                       # Read from STDIN
    bsign -P '--passphrase-file /path/to/file-or-pipe' ... # Read from a file
    bsign -P '--passphrase "my password"' ...              # Pass password as parameter
    

    If the second or third option, make sure you're escaping properly as the parameter's contents will be parsed again (eg. \\\\ if your password contains a single backslash).