Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to encrypt something with gpg -a and return the result to standard out rather than a file. According to the manual, it should be sufficient to omit an --output flag, but that doesn't seem to be the case. When I don't specify an output file, gnupg assumes I'm outputting to [input-file].gpg rather than stdout.

Is there a way to have GPG do this, or am I going to have to have it encrypt to a temporary file and then cat it?

share|improve this question
up vote 4 down vote accepted

Instead of passing the input file to gpg, use shell redirection to send the input file to gpg's stdin, e.g.:

gpg -ac < inputfile
share|improve this answer

Just in case anyone still needs to do this, you can do it with

gpg -ac -o- infile

Setting the output filename to "-" sends the output to stdout.

share|improve this answer

edit: sorry realised you wanted symmetric encryption

gpg -a -c prompt will come up for the password, after that type your message then press ctrl+d

gpg -a --encrypt -r

then type message, when you're done press ctrl+d

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.