{"id":46532,"date":"2024-05-07T16:30:53","date_gmt":"2024-05-07T16:30:53","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=46532"},"modified":"2024-07-23T12:16:19","modified_gmt":"2024-07-23T12:16:19","slug":"encrypt-home-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/05\/encrypt-home-ubuntu-24-04\/","title":{"rendered":"How to Encrypt Your Home Folder in Ubuntu 24.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/ecryptfs-mascot.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-46534\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/ecryptfs-mascot-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/ecryptfs-mascot-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/ecryptfs-mascot-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/ecryptfs-mascot-700x700.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/ecryptfs-mascot-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/ecryptfs-mascot.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This is a step by step beginner&#8217;s guide shows how to encrypt your home directory in Ubuntu 24.04 LTS.<\/p>\n<p>As you may know, the new installer in Ubuntu 24.04 only supports encrypting the entire disk. If you want to dual boot Ubuntu with another OS in single disk, there&#8217;s no option so far to encrypt only the Ubuntu file-system partition.<\/p>\n<p><b>In the case, you may choose to encrypt your home folder to keep personal data and files safe.<\/b><\/p>\n<p>There&#8217;s NO visible difference after encrypted your home directory. You can login just like before, read and write files, run apps and play games. Because, it&#8217;s automatically decrypted using your password.<\/p>\n<p>But, if you lost your computer\/laptop, then no one can access your files in the home folder, without the login password or the encryption passphrase. Accessing from another operating system will show something like the screenshot below shows you:<\/p>\n<div id=\"attachment_46535\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/unaccessable.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-46535\" class=\"size-large wp-image-46535\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/unaccessable-700x465.webp\" alt=\"\" width=\"610\" height=\"405\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/unaccessable-700x465.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/unaccessable-300x199.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/unaccessable-768x510.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/unaccessable.webp 1012w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><p id=\"caption-attachment-46535\" class=\"wp-caption-text\">Encrypted home is not accessible from other machine or OS<\/p><\/div>\n<p><!--more--><\/p>\n<h3>Step 1: Install the encryption tool<\/h3>\n<p>Ubuntu installer used to have an option to encrypt home folder, which uses eCryptfs for encryption. However, this option is no longer available in Ubuntu 24.04 installer.<\/p>\n<p>To install the tool, press <code>Ctrl+Alt+T<\/code> to open up a terminal window and run command:<\/p>\n<pre>sudo apt install ecryptfs-utils cryptsetup<\/pre>\n<p><i>Run <code>sudo apt update<\/code> to refresh package cache if the package not found.<\/i><br \/>\n<a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/apt-encrypt-utility.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46536\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/apt-encrypt-utility-700x508.webp\" alt=\"\" width=\"610\" height=\"443\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/apt-encrypt-utility-700x508.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/apt-encrypt-utility-300x218.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/apt-encrypt-utility-768x558.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/apt-encrypt-utility.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Step 2: Create a temporary admin account<\/h3>\n<p>You need to log out the user account, whose home folder you want to encrypt. And, use another admin account to do the encryption process.<\/p>\n<p>To create a temporary admin account in Ubuntu Desktop, do:<\/p>\n<ol>\n<li>Open &#8220;Settings&#8221; from top-right system status menu (aka Quick Settings).<\/li>\n<li>In &#8220;Settings&#8221;, navigate to <code>System -&gt; Users<\/code><\/li>\n<li>Next, click Unlock -&gt; Add User &#8230;<\/li>\n<li>Finally, insert a username, enable &#8220;Administrator&#8221; option, and set password.<\/li>\n<\/ol>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/create-tempadmin.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46537\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/create-tempadmin-700x514.webp\" alt=\"\" width=\"610\" height=\"448\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/create-tempadmin-700x514.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/create-tempadmin-300x220.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/create-tempadmin-768x563.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/create-tempadmin.webp 1258w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>For Ubuntu Server, simply run the command below to add user. In the process, it will ask to set a password for the new account, and configure some user information (it&#8217;s OK to hit Enter for all).<\/p>\n<pre>sudo adduser temp_user<\/pre>\n<p>Then, grant sudo permission to the account by running command.<\/p>\n<pre>sudo usermod -aG sudo temp_user<\/pre>\n<h3>Step 3: Encrypt home folder<\/h3>\n<p>Now, log out the user account whose home folder you want to encrypt. Then, login with the new admin account (<code>temp_user<\/code> in the case).<\/p>\n<p><b>NOTE: The command below will make a backup of the home folder! Just in case, it&#8217;s BETTER to manually do an additional backup of your important data.<\/b><\/p>\n<p>1. After logged in with the temporary admin account, press <code>Ctrl+Alt+T<\/code> to open terminal, and run command:<\/p>\n<pre>sudo ecryptfs-migrate-home -u THE_USER_NAME<\/pre>\n<p><i>Replace the THE_USER_NAME in command with the username whose home folder you want to encrypt.<\/i><\/p>\n<p>The command will first asks for typing the current temporary user&#8217;s password for permission running this command, then asks for target user&#8217;s password.<br \/>\n<a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-ji.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46538\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-ji-700x508.webp\" alt=\"\" width=\"610\" height=\"443\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-ji-700x508.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-ji-300x218.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-ji-768x558.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-ji.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>2. When done, you should get the following terminal screen with some notices. They include:<\/p>\n<ul>\n<li><b>MUST login the encrypted user to finish the process before reboot!<\/b><\/li>\n<li>Restore the backup file &#8220;\/home\/username.xxxxxx&#8221; if something goes wrong.<\/li>\n<li>The command to get the auto-generated passphrase.<\/li>\n<li>Command to also encrypt the swap area.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-done-notice.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46539\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-done-notice-700x508.webp\" alt=\"\" width=\"610\" height=\"443\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-done-notice-700x508.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-done-notice-300x218.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-done-notice-768x558.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-done-notice.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Step 4: Log back the encrypted user to generate passphrase<\/h3>\n<p>If everything goes well, log out the temporary admin account, and log back with the user account whose home is encrypted.<\/p>\n<p>1. After login, it will pop-up a dialog as the screenshot below shows you (<i>there may be a few seconds delay according to your device<\/i>).<\/p>\n<p>Just click on &#8220;<strong>Run this action now<\/strong>&#8221; button, then type your password (the password for login) and hit Enter in the pop-up terminal window. It will generate a random passphrase for recover purpose, in case your system refuse to boot or broken in future.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/auto-generate-passpharse.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46540\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/auto-generate-passpharse-700x348.webp\" alt=\"\" width=\"610\" height=\"303\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/auto-generate-passpharse-700x348.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/auto-generate-passpharse-300x149.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/auto-generate-passpharse-768x382.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/auto-generate-passpharse.webp 1296w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>2. To get the auto-generated passphrase, just run command:<\/p>\n<pre>ecryptfs-unwrap-passphrase<\/pre>\n<p>Then copy and keep the output passphrase in safe place!<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-show-pass.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46541\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-show-pass-700x200.webp\" alt=\"\" width=\"610\" height=\"174\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-show-pass-700x200.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-show-pass-300x86.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-show-pass-768x219.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-show-pass.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Step 5: Encrypt the Swap Area<\/h3>\n<p>To ensure the integrity of all encrypted data, you should also encrypt the swap area.<\/p>\n<p><b>NOTE: This step will break the hibernate and suspend feature!<\/b><\/p>\n<p>1. First, open up a terminal window (Ctrl+Alt+T) and run command to check if you have a swap area:<\/p>\n<pre>swapon -s<\/pre>\n<p>If there&#8217;s no swap partition or swap file in use, you can just skip this step.<\/p>\n<p>2. Then, run command to encrypt the swap:<\/p>\n<pre>sudo ecryptfs-setup-swap<\/pre>\n<p>The command output &#8220;<i>swapon: cannot open \/dev\/mapper\/cryptswap1: No such file or directory<\/i>&#8220;.<\/p>\n<p>However, it works after a <b>system reboot<\/b>. Just run <code>swapon -s<\/code> to verify. The encrypted swap will look like <code>\/dev\/dm-0<\/code>.<br \/>\n<a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-swap.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46542\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-swap-700x508.webp\" alt=\"\" width=\"610\" height=\"443\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-swap-700x508.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-swap-300x218.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-swap-768x558.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/encrypt-swap.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Step 6: Clean Up<\/h3>\n<p>If everything&#8217;s done successfully, you can now remove the temporary admin user, and delete the auto-generated backup folder.<\/p>\n<p><b>To delete the temporary account,<\/b> either open &#8220;Settings&#8221;, navigate to <code>System<\/code> -&gt; <code>Users<\/code>, click &#8220;Unlock&#8221;, select the temporary user account and finally click &#8220;Remove User&#8221; button to remove it.<\/p>\n<p>Or, run the commands below in terminal instead:<\/p>\n<pre>sudo userdel --remove temp_user<\/pre>\n<p>To delete the auto-generated backup, use command:<\/p>\n<pre>sudo rm -rf \/home\/ji.jjf1M2qF<\/pre>\n<p><i>Replace <b>ji.jjf1M2qF<\/b> in command accordingly. Go Files -&gt; Other Locations -&gt; Ubuntu -&gt; home to check the backup folder name.<\/i><\/p>\n<h3>Summary<\/h3>\n<p>In this tutorial, I&#8217;ve shown you how to encrypt the home directory in Ubuntu 24.04 LTS.<\/p>\n<p>In short, user just needs to install the <code>ecryptfs<\/code> utility, run the encryption command using another admin account, and login back to generate the passphrase in pop-up dialog for recover purpose. And, run one more command to encrypt the swap file or partition.<\/p>","protected":false},"excerpt":{"rendered":"<p>This is a step by step beginner&#8217;s guide shows how to encrypt your home directory in Ubuntu 24.04 LTS. As you may know, the new installer in Ubuntu 24.04 only supports encrypting the entire disk. If you want to dual boot Ubuntu with another OS in single disk, there&#8217;s no option so far to encrypt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":46534,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[2039,2087],"class_list":["post-46532","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-security","tag-ubuntu-24-04"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/46532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=46532"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/46532\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/46534"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=46532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=46532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=46532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}