{"id":323,"date":"2009-10-04T07:59:21","date_gmt":"2009-10-04T07:59:21","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2009\/10\/04\/password-protect-and-encryptsalt-a-file-with-openssl-in-linux\/"},"modified":"2023-01-06T16:45:51","modified_gmt":"2023-01-06T16:45:51","slug":"password-protect-and-encryptsalt-a-file-with-openssl-in-linux","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/UNIX\/Linux\/password-protect-and-encryptsalt-a-file-with-openssl-in-linux.html","title":{"rendered":"Linux: Password Protect & Encrypt File Using OpenSSL"},"content":{"rendered":"
In this article we will encrypt (using AES 256 cbc) and password protect (Salt the AES) a file using the openssl binary.<\/p>\n
The file we will encrypt will be the file secretfile.txt.As you can see it is just a plain text file.<\/p>\n
[root@linux tmp]# cat\u00a0 secretfile.txt
\nThis is a secret file that we do not want anyone to read.<\/p>\n
Encrypt File<\/strong><\/span><\/p>\n Use the openssl comand to encrypt your file and then test the new file is fully encrypted.<\/p>\n [root@linux tmp]# openssl aes-256-cbc -salt -in secretfile.txt -out secretfile.txt.aes [root@linux tmp]# cat\u00a0 secretfile.txt.aes Decrypt File<\/span><\/strong><\/p>\n Decrypt the file and then confirm the decypted file is readable.<\/p>\n [root@linux tmp]# openssl aes-256-cbc -d -salt -in secretfile.txt.aes -out secretfile.txt [root@linux tmp]# cat secretfile.txt Further notes : <\/em><\/strong>In a non-interactive scenario (such as using this within a script) were you require no input from the shell (user), you can use the -k to specify the password. Such as `openssl aes-256-cbc -salt -in secretfile.txt -out secretfile.txt.aes -k [password]`.<\/p>\n \u00a0<\/span><\/p>\n","protected":false},"excerpt":{"rendered":" In this article we will encrypt (using AES 256 cbc) and password protect (Salt the AES) a file using the openssl binary. The file we will encrypt will be the file secretfile.txt.As you can see it is just a plain text file. [root@linux tmp]# cat\u00a0 secretfile.txt This is a secret file that we do not … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52],"tags":[],"yoast_head":"\n
\nenter aes-256-cbc encryption password:
\nVerifying – enter aes-256-cbc encryption password:<\/p>\n
\n3b\u00a6ted__\u00d9.:SL\u00ec\u00d5\u00a7\u00d5L<Jdc
\nu3A\u00c8F\\V!\u00ea:S2;\u00b3\u00e2\u00ff.Lfj\u00cf\u00a9\u00f9!_b*&)Stf\u00f9<\/p>\n
\nenter aes-256-cbc decryption password:<\/p>\n
\nThis is a secret file that we do not want anyone to read.<\/p>\n