That given, you can use: qpdf -decrypt protected.pdf out. If you have an older version of qpdf (prior to v10.2.0), -password-file= didn't work this way, but one could still read a whole argument from stdin with the option. Check the Unlock PDF limits for each account type. Our tool will unlock your document by removing its password. In Windows, I think it would be Ctrl+ z, but I'm not sure). as per the site Documentation: To remove the password from a PDF file, upload the document from your device or straight from your Google Drive or Dropbox account. You can then type, RET and Ctrl+ d ( Ctrl+ d sends EOF in Linux. Once you enter that, qpdf will be waiting for input from stdin. qpdf can read a password from stdin passing - to the -password-file= option: qpdf -password-file=-decrypt protected.pdf out.pdf The password is then queried in the terminal and you can type it.
With pdftk we can use: pdftk protected.pdf input_pw output out.pdf do_ask But maybe you received a pdf from a company which used some data of yours to encrypt the file, and you'd like to avoid leaking it. Of course, since this is about removing the password protection from the file, maybe you don't care. This is an old question, but seems to be a reference on the matter and, surprisingly, none of the answers tells us how to avoid passing the password on the command line (which may be a source of leakage).