Command line: how to ecrypt a file (and its decryption too)

Linux terminal encryption comes with openssl:

openssl aes-256-cbc -in input-file.txt -out encrypted.txt -pass pass:somepassword

For the decryption just add the -d switch:

openssl aes-256-cbc -d -out input-file.txt -in encrypted.txt -pass pass:somepassword


the “pass:” before the actual plain text password tells is mandatory. Another option would be “file:” to use the first line of a file as password. Omitting the -pass parameter will result in an interactive prompt asking the password.
OpenSSL supports several encodings and encryption, from base64 to blowfish and so and forth (see man openssl for the full list).

Advertisements