{"id":4424,"date":"2012-03-15T15:57:38","date_gmt":"2012-03-15T19:57:38","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/?p=4424"},"modified":"2012-03-15T15:57:38","modified_gmt":"2012-03-15T19:57:38","slug":"file-password-protection","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/file-password-protection\/","title":{"rendered":"File Password Protection"},"content":{"rendered":"<p><strong>How do I password protect \/ encrypt a file within Linux using OpenSSL ?<\/strong><\/p>\n<p>The file we will encrypt will be the file secretfile.txt.As you can see it is just a plain text file.<\/p>\n<p><strong>Encrypt File<\/strong><\/p>\n<p>Use the openssl comand to encrypt your file and then test the new file is fully encrypted.<\/p>\n<p><code>$ openssl aes-256-cbc -salt -in secretfile.txt -out secretfile.txt.aes<br \/>\nenter aes-256-cbc encryption password:<br \/>\nVerifying \u2013 enter aes-256-cbc encryption password:<\/p>\n<p>$ cat secretfile.txt.aes<br \/>\nbinary data<\/code><\/p>\n<p><strong>Decrypt File<\/strong><\/p>\n<p>Decrypt the file and then confirm the decypted file is readable.<\/p>\n<p><code>$ openssl aes-256-cbc -d -salt -in secretfile.txt.aes -out secretfile.txt<br \/>\nenter aes-256-cbc decryption password:<\/p>\n<p>$ cat secretfile.txt<br \/>\nThis is a secret file that we do not want anyone to read.<\/code><\/p>\n<p>======================================<!--more--><\/p>\n<p><strong>How do I password protect \/ encrypt a file within Linux using Mcrypt?<\/strong><br \/>\n<strong>Encrypt File<\/strong><\/p>\n<p>Use the mcrypt comand to encrypt your file and then test the new file is fully encrypted.<\/p>\n<p><code>$ mcrypt secretfile.txt<\/p>\n<p>Output:<br \/>\nEnter the passphrase (maximum of 512 characters)<br \/>\nPlease use a combination of upper and lower case letters and numbers.<br \/>\nEnter passphrase:<br \/>\nEnter passphrase:<\/code><\/p>\n<p>A new file is created with the extension .nc<\/p>\n<p><code>$ ls secretfile.txt.nc<\/code><\/p>\n<p><strong>Decrypt File<\/strong><\/p>\n<p>Decrypt the file and then confirm the decypted file is readable.<\/p>\n<p><code>$ mcrypt -d secretfile.txt.nc<\/p>\n<p>Output:<\/p>\n<p>Enter passphrase:<br \/>\nFile secretfile.txt.nc was decrypted.<\/code><\/p>\n<p>======================================<\/p>\n<p><strong>How do I password protect \/ encrypt a file within Linux using GPG?<\/strong><br \/>\n<strong>Encrypt File<\/strong><\/p>\n<p>Use the gpg comand to encrypt your file and then test the new file is fully encrypted.<\/p>\n<p><code>$ gpg -c secretfile.txt<\/p>\n<p>Output:<br \/>\nEnter passphrase:<br \/>\nRepeat passphrase:<br \/>\n<\/code><br \/>\nThis will create a secretfile.txt.gpg file.<\/p>\n<p><strong>Decrypt File<\/strong><\/p>\n<p>Decrypt the file and then confirm the decypted file is readable.<\/p>\n<p><code>$ gpg secretfile.txt.gpg<\/code><\/p>\n<p>Decrypt file and write output to file<\/p>\n<p><code>$ gpg secretfile.txt.gpg -o somefile.txt<\/code><\/p>\n<p>======================================<\/p>\n<p>In all of the examples above we need to remove the original document once the new file is created.<\/p>\n<p>======================================<\/p>\n<p>Easiest method is to create a file using vim with the -x flag<\/p>\n<p><code>vim -x<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How do I password protect \/ encrypt a file within Linux using OpenSSL ? The file we will encrypt will be the file secretfile.txt.As you can see it is just a plain text file. Encrypt File Use the openssl comand to encrypt your file and then test the new file is fully encrypted. $ openssl&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/file-password-protection\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-4424","post","type-post","status-publish","format-standard","hentry","category-cli"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>File Password Protection - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/file-password-protection\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"File Password Protection - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"How do I password protect \/ encrypt a file within Linux using OpenSSL ? The file we will encrypt will be the file secretfile.txt.As you can see it is just a plain text file. Encrypt File Use the openssl comand to encrypt your file and then test the new file is fully encrypted. $ openssl... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/file-password-protection\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2012-03-15T19:57:38+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/file-password-protection\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/file-password-protection\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"File Password Protection\",\"datePublished\":\"2012-03-15T19:57:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/file-password-protection\\\/\"},\"wordCount\":213,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"CLI\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/file-password-protection\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/file-password-protection\\\/\",\"name\":\"File Password Protection - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2012-03-15T19:57:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/file-password-protection\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/file-password-protection\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/file-password-protection\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"File Password Protection\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"File Password Protection - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/file-password-protection\/","og_locale":"en_US","og_type":"article","og_title":"File Password Protection - Linux Shtuff","og_description":"How do I password protect \/ encrypt a file within Linux using OpenSSL ? The file we will encrypt will be the file secretfile.txt.As you can see it is just a plain text file. Encrypt File Use the openssl comand to encrypt your file and then test the new file is fully encrypted. $ openssl... Read More","og_url":"https:\/\/g33kinfo.com\/info\/file-password-protection\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2012-03-15T19:57:38+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/file-password-protection\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/file-password-protection\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"File Password Protection","datePublished":"2012-03-15T19:57:38+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/file-password-protection\/"},"wordCount":213,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["CLI"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/file-password-protection\/","url":"https:\/\/g33kinfo.com\/info\/file-password-protection\/","name":"File Password Protection - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2012-03-15T19:57:38+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/file-password-protection\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/file-password-protection\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/file-password-protection\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"File Password Protection"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/4424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=4424"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/4424\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=4424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=4424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=4424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}