I can compress a 7zip archive with encryption like this:
7z a -pSECRET example.7z *.doc
But in this case I specify the password (SECRET
) literally on the command line.
Is it also possible to specify a filename that contains the password? E.g. something like this:
7z a -p@passwordfile.txt example.7z *.doc
Except this doesn't work, in this case it will encrypt the archive literally using the password '@passwordfile.txt'.
Is there another way to go about this?
-p"$(cat passwordfile.txt)"
, or maybe(read secret < passwordfile.txt; 7z a -p"$secret" example.7z *.doc)
ps -aux | grep 7z
in another shell while it's encrypting, it shows the password there. And possibly it's even being logged in~/.bash_history
. I was hoping for a possibility of 7z itself to specify a password in a file, but maybe such a feature simply isn't there?