I believe coralfang's method is better than mine because the password is store in a file. My method above will hide the password
but it requires interaction from you.
If you want to make a strong password for your rar archive and store it in a file, you can run this command
Code:
tr -dc [:graph:] < /dev/urandom | head -c 15 | xargs -0 > somefile
This will produce a 15 character random string of numbers, letters and symbols. You can adjust the length of the string by changing the value in red.
Next, chmod your file, like so
Only the owner will have read-write access to the file and blocked to everyone else.
Now you can run the command that coralfang gave you
Code:
rar a folder.rar -hp`cat somefile`