This tutorial helps you encrypt and decrypt a file with OpenSSL and GPG.
Note that it is recommended to use GPG.
Source: https://stackoverflow.com/questions/28247821/openssl-vs-gpg-for-encrypting-off-site-backups
gpg --output encrypted.data --symmetric --cipher-algo AES256 un_encrypted.datagpg --output un_encrypted.data --decrypt encrypted.dataopenssl enc -e -cipher -salt [-S SALT] -k PASSWORD -in INPUT_FILE -out OUTPUT_FILEwith:
-cipherbeing a cipher (like-aes-256-cbc). The full list of supported cipher can be accessed by typingopenssl enc -ciphersor by reading the fileOpenSSL-supported-ciphers.txtbelow.-saltto specify to add a random salt. You can specify the salt with-salt -S SALT(SALTmust be an hexadecimal value), or disable the salt with-nosalt.-k PASSWORDthe password that will protect the file. If not given, it will be read from the terminal (recommended). you can also pass-kfile FILEto read the password from a file.-in INPUT_FILEThe file to encrypt.-out OUTPUT_FILEThe encrypted file that will be created at the end.
openssl enc -d -cipher -salt [-S SALT] -k PASSWORD -in INPUT_FILE -out OUTPUT_FILEwith:
-cipherbeing a cipher (like-aes-256-cbc). The full list of supported cipher can be accessed by typingopenssl enc -ciphersor by reading the fileOpenSSL-supported-ciphers.txtbelow. It must be the same cipher for encryption and decryption.-saltto specify to add a random salt. You can specify the salt with-salt -S SALT(SALTmust be an hexadecimal value), or disable the salt with-nosalt. It must be the same parameter for encryption and decryption.-k PASSWORDthe password that protects the file. If not given, it will be read from the terminal (recommended). you can also pass-kfile FILEto read the password from a file. It must be the same password for encryption and decryption.-in INPUT_FILEThe encrypted file.-out OUTPUT_FILEThe decrypted file that will be created at the end.
To encrypt multiple files with GPG or OpenSSL, you must first compress them using tar(1).
To compress multiple files or directories:
tar czf myfiles.tar.gz file1 file2 mydirectory/Once you have decrypted the files, you need to uncompress them:
tar xzf myfiles.tar.gz