{"id":3153,"date":"2016-11-04T17:29:23","date_gmt":"2016-11-04T21:29:23","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=3153"},"modified":"2017-12-12T16:07:57","modified_gmt":"2017-12-12T21:07:57","slug":"encrypt-directory-ecryptfs-ubuntu-16","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/","title":{"rendered":"How to encrypt a directory with eCryptfs on Ubuntu 16"},"content":{"rendered":"<h1>How to encrypt a directory with eCryptfs on Ubuntu 16<\/h1>\n<p>Ecryptfs is a powerful but simple to use tool for encrypting directories. Perhaps you are keeping sensitive information in your home directory, and wish to secure those files from an attacker who gains access to your server but not your user credentials. Or maybe your database contains sensitive details that you wish to encrypt at rest. With Ecryptfs, it is easy to secure individual directories in a way that they cannot be accessed without a user logging into the account that owns the key. In this guide, we&#8217;ll encrypt the contents of a directory on an Ubuntu 16.04 server.<\/p>\n<h2>Getting Started<\/h2>\n<p>You&#8217;ll need the following in place before we begin:<br \/>\n\u2022 1 server (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\">Cloud Server<\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\">Dedicated Server<\/a>), running a fresh installation of Ubuntu 16.04.<br \/>\n\u2022 Root access<\/p>\n<h2>Tutorial<\/h2>\n<p>Begin by installing the necessary packages.<\/p>\n<p><code>apt-get install ecryptfs-utils -y<\/code><\/p>\n<p>File encryption is a powerful tool, but its capabilities and limitations need to be understood before it is used for serious tasks. For purposes of illustration, we&#8217;ll create a test directory in \/home so you can get a sense for how your encrypted filesystem will work.<\/p>\n<p><code>mkdir \/home\/globotech<\/code><\/p>\n<p>Now we&#8217;ll encrypt the contents of the globotech directory we&#8217;ve just made.<\/p>\n<p><code>mount -t ecryptfs \/home\/globotech\/ \/home\/globotech\/<\/code><\/p>\n<p>You&#8217;ll be prompted to choose a password, and to set an encryption type.<\/p>\n<p>With these set, check if the contents of the directory are encrypted.<\/p>\n<p><code>mount<\/code><\/p>\n<p><code class=\"gris\">[...]<br \/>\ncpu,cpuacct on \/run\/lxcfs\/controllers\/cpu,cpuacct type cgroup (rw,relatime,cpu,cpuacct,nsroot=\/)<br \/>\ndevices on \/run\/lxcfs\/controllers\/devices type cgroup (rw,relatime,devices,nsroot=\/)<br \/>\nblkio on \/run\/lxcfs\/controllers\/blkio type cgroup (rw,relatime,blkio,nsroot=\/)<br \/>\nname=systemd on \/run\/lxcfs\/controllers\/name=systemd type cgroup (rw,relatime,xattr,release_agent=\/lib\/systemd\/systemd-cgroups-agent,name=systemd,nsroot=\/)<br \/>\nlxcfs on \/var\/lib\/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)<br \/>\ntmpfs on \/run\/user\/0 type tmpfs (rw,nosuid,nodev,relatime,size=101628k,mode=700)<br \/>\n\/home\/globotech on \/home\/globotech type ecryptfs (rw,relatime,ecryptfs_sig=9cff1b579bb64c22,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_unlink_sigs) <\/code><\/p>\n<p>Next we&#8217;ll add a file with test content to this directory.<\/p>\n<p><code>touch \/home\/globotech\/file.txt<br \/>\necho \"Good Morning\" &gt; \/home\/globotech\/file.txt<\/code><\/p>\n<p>Unmount the encrypted globotech directory.<\/p>\n<p><code>umount \/home\/globotech<\/code><\/p>\n<p>With the directory unmounted, try to read the file you&#8217;ve just created.<\/p>\n<p><code>cat \/home\/globotech\/file.txt<\/code><\/p>\n<p><code class=\"gris\">z6&lt;\"3DUfw`M\\`<br \/>\nW_65\"I??_aO?EXgd+?+-\u00a0\u00a0 RK[a+?`,[-+=?Mec8 Td8Y\u00a0 ?IV-[2d!fXMQYeQS+?!-SB<br \/>\ng7?%?\u00bchH+H?'F\\++}H.+I;?2-\/I!P[KE)<br \/>\nE<br \/>\nDFL'|Ug{_:4?2T0G-\\H:<br \/>\n1q?X\u00a0\u00a0\u00a0 vfq?,Xy*e~ox&lt;lI619q2?~&lt;\u00a0\u00a0 Q6):O%8 _&amp;+)sMYW0lS!;0?n%#??5\u00ff?D}F?j_sWNv<br \/>\nB<br \/>\nZakBD<br \/>\n;T?t[IZlAOs]0??Q)N~Pp&amp;hIbG@,?f<br \/>\n[...]<\/code><\/p>\n<p>You&#8217;ll notice that the file is encrypted and the content is inaccessible. Without the password, an attacker cannot gain access to the file you&#8217;ve just made.<\/p>\n<p>If you&#8217;d like access to your file again, run the same command you ran previously:<\/p>\n<p><code>mount -t ecryptfs \/home\/globotech\/ \/home\/globotech\/<\/code><\/p>\n<p>Use the same password to access your files. Please keep this password safe. If it is lost, no one will be able to regain access to your files, not even your service provider.<\/p>\n<p><code>cat \/home\/globotech\/file.txt<\/code><\/p>\n<p><code class=\"gris\">Good Morning<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>Encryption is a powerful way to protect your files in the event of a compromised server or stolen laptop. Everyone should encrypt their sensitive data, so share this article with anyone who may not know how easy encrypting directories can be. If you found this article helpful, feel free to share it with your friends and let us know in the comments below!<\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to encrypt a directory with eCryptfs on Ubuntu 16 Ecryptfs is a powerful but simple to use tool for encrypting directories. Perhaps you are keeping sensitive information in your home directory, and wish to secure those files from an attacker who gains access to your server but not your user credentials. Or maybe your<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"class_list":["post-3153","post","type-post","status-publish","format-standard","hentry","category-security","operating_system-ubuntu-16-04"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to encrypt a directory with eCryptfs on Ubuntu 16 - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to encrypt a directory with eCryptfs on your Ubuntu 16 server. Read now &amp; Start encrypting directories!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to encrypt a directory with eCryptfs on Ubuntu 16 - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to encrypt a directory with eCryptfs on your Ubuntu 16 server. Read now &amp; Start encrypting directories!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-11-04T21:29:23+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-12T21:07:57+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"963\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/\",\"name\":\"How to encrypt a directory with eCryptfs on Ubuntu 16 - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"datePublished\":\"2016-11-04T21:29:23+00:00\",\"dateModified\":\"2017-12-12T21:07:57+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to encrypt a directory with eCryptfs on your Ubuntu 16 server. Read now & Start encrypting directories!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to encrypt a directory with eCryptfs on Ubuntu 16\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to encrypt a directory with eCryptfs on Ubuntu 16 - Globo.Tech","description":"This tutorial will show you how to encrypt a directory with eCryptfs on your Ubuntu 16 server. Read now & Start encrypting directories!","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:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/","og_locale":"en_US","og_type":"article","og_title":"How to encrypt a directory with eCryptfs on Ubuntu 16 - Globo.Tech","og_description":"This tutorial will show you how to encrypt a directory with eCryptfs on your Ubuntu 16 server. Read now & Start encrypting directories!","og_url":"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/","og_site_name":"Globo.Tech","article_published_time":"2016-11-04T21:29:23+00:00","article_modified_time":"2017-12-12T21:07:57+00:00","og_image":[{"width":1920,"height":963,"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/GloboTech-Logo.png","type":"image\/png"}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/","url":"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/","name":"How to encrypt a directory with eCryptfs on Ubuntu 16 - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"datePublished":"2016-11-04T21:29:23+00:00","dateModified":"2017-12-12T21:07:57+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to encrypt a directory with eCryptfs on your Ubuntu 16 server. Read now & Start encrypting directories!","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/encrypt-directory-ecryptfs-ubuntu-16\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to encrypt a directory with eCryptfs on Ubuntu 16"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3153","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=3153"}],"version-history":[{"count":5,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3153\/revisions"}],"predecessor-version":[{"id":4020,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/3153\/revisions\/4020"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=3153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=3153"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=3153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}