I am found of keeping password protected backups and most of the time I lost my super secret password thus unable to open my super important backups just kidding.
Like in windows we can simple right click and zip folders/files with passwords in text based terminals of linux I always want the same.
So here is the trick I normally use.
For encrypting a file:
1 | openssl enc -aes-256-cbc -e > out. file |
It will ask for password like:
1 | enter aes-256-cbc encryption password: |
2 | Verifying - enter aes-256-cbc encryption password: |
If you want to encrypt a folder with compression (tar.gz)
1 | tar -cz foldername | openssl enc -aes-256-cbc -e > out. tar .gz |
Now the important part, decrypting your encrypted files….
1 | openssl enc -aes-256-cbc -d - in out. file > new. file |