Passphrase command not working

I’m hoping someone can help me decrypt a file using the passphrase option.

This is my command:
gpg.exe -v --batch --passphrase “the-pw-here” --output c:\temp\fileout.txt --decrypt c:\temp\filein.csv.asc

This is my error:
gpg: public key decryption failed: Bad passphrase
gpg: decryption failed: No secret key

I’ve also tried passphrase-fd 0 and passphrase-file

Any ideas what I’m doing wrong? I know my passphrase is good because it works when I enter it via the prompt box.


It says you do not have the secret key. Are you trying to decrypt a file that you encrypted for someone else using their public key? If so give up. You can only encrypt with a public key you cannot decrypt with it. If this file was encrypted with your public key by someone else you need your passphrase and the secret key needs to be on your key ring. If someone else at your company created the key pair (secret/public) you will need them to export both public and secret keys and you will need to import them on to your keyring.

Greg, thanks for your response!

The file I am decrypting was encrypted using my public key at another site. I copied the file to my server and can successfully decrypt but only when I enter the passphrase manually. The below is now errors "gpg: handle plaintext failed: General error ". ’

Any ideas? Is there a way to enter the passphrase manually and keep it cached so I won’t need this passphrase in my scripts?


Current Error
C:\Program Files\GNU\GnuPG>gpg.exe -v --batch -a --passphrase mypassphrase --output c:\temp\enrol4.txt --decrypt c:\temp\enrollment20150505.csv.asc

gpg: armor header: Version: GnuPG v1.2.2 (MingW32)

gpg: public key is B3E28F3B
gpg: using subkey B3E28F3B instead of primary key DD353986
gpg: using subkey B3E28F3B instead of primary key DD353986
gpg: encrypted with 4096-bit RSA key, ID B3E28F3B, created 2015-04-24
gpg: AES256 encrypted data
gpg: original file name=‘Enrollment20150505.csv’
gpg: handle plaintext failed: General error

C:\Program Files\GNU\GnuPG>

I got it!!!

This command works:
gpg.exe -v --batch -a --passphrase mypw --output c:\fileout.csv --decrypt c:\temp\enrollment20150505.csv.asc

It appears you can’t replace the decrypted document with a new one on the batch option.