systemd-homed Explained: Portable, Self-Contained Encrypted Home Directories
A conventional Linux user is spread across several places: a line in /etc/passwd, a hash in /etc/shadow, group memberships in /etc/group, and a directory in /home. None of those travel together, which is why moving a user between machines means recreating the account.
systemd-homed puts all of it inside the home directory.
The model
A home area is a self-contained unit holding:
- The user’s files
- A JSON user record describing the account: uid, shell, groups, password hashes, quotas
- Optionally, encryption around the whole thing
# is it running
systemctl status systemd-homed
# what homes exist
homectl list
homectl inspect colton
Because the record lives inside the home area, the host does not need to know about the account in advance. Plug in a drive containing a home area, and the machine can authenticate against the record inside it and log you in.
That is the design goal: a home directory you can carry.
Creating one
sudo homectl create alice \
--real-name="Alice Example" \
--storage=luks \
--disk-size=50G \
--member-of=wheel \
--shell=/bin/bash \
--fs-type=btrfs
homectl inspect alice
homectl list
# changing things later
sudo homectl update alice --disk-size=80G
sudo homectl update alice --member-of=wheel,docker
sudo homectl passwd alice
# lock, unlock, remove
sudo homectl lock alice
sudo homectl unlock alice
sudo homectl remove alice
homectl update changing group membership is worth noting: on a conventional account that means editing /etc/group, per our users and groups guide. Here the membership is a property of the user record.
Storage backends
The choice that determines what you actually get.
--storage= | What it is | Encrypted |
|---|---|---|
luks | LUKS image in a loopback file | Yes |
fscrypt | Per-directory kernel encryption | Yes |
subvolume | Btrfs subvolume | No |
directory | A plain directory | No |
cifs | A remote CIFS share | In transit |
luks is the one that justifies homed. The home area is a .home image file containing a LUKS container, unlocked by your password at login and locked again at logout.
ls -lh /home/*.home
sudo cryptsetup luksDump /home/alice.home 2>/dev/null | head
subvolume gives you per-user quotas and snapshots on Btrfs without encryption, which is a legitimate reason to use homed on a machine that already has full disk encryption.
How this differs from full disk encryption
Worth being precise, because they are complementary rather than competing.
LUKS full disk encryption unlocks once at boot. After that the whole disk is readable by anything with sufficient privilege, including every user’s home directory.
homed with luks storage encrypts each home separately, unlocked by that user’s own password at their login. A logged-out user’s home stays encrypted while the machine is running.
Which matters on a shared machine: with full disk encryption only, root can read every home. With homed, root can read the home areas that happen to be unlocked.
The stronger arrangement is both: full disk encryption so the system itself is protected at rest, and homed so homes are protected from each other while running. Our encrypting your installation guide covers the first, and TPM unlock covers making it convenient.
The things that break
Being direct, because this is why adoption has been slow.
ssh with keys
# this is the problem
~/.ssh/authorized_keys
authorized_keys lives inside the encrypted home. sshd needs to read it before the user has authenticated, and the home is locked until they do.
So key-based login does not work in the usual way. The workarounds:
- Password authentication for the login that unlocks the home, which conflicts with the advice in our ssh hardening guide
- Keys stored outside the home, with
AuthorizedKeysFilepointing at/etc/ssh/authorized_keys/%u - An ssh certificate authority, where the server validates a signature rather than reading a file. This is the cleanest answer and is worth knowing about independently
# /etc/ssh/sshd_config
AuthorizedKeysFile /etc/ssh/authorized_keys/%u .ssh/authorized_keys
Services that expect a readable home
Anything running as the user without an interactive login finds no home directory. Cron jobs, systemd user services before first login, backup agents.
homectl can enable lingering-like behaviour, and the fundamental tension remains: an encrypted-at-rest home cannot be read by a service when nobody has unlocked it.
NFS and network homes
A .home image on an NFS share works poorly. The loopback and locking semantics do not survive the round trip reliably.
uid allocation
homed assigns uids from a range, and they are not the same on different machines unless the record is carried along. Which is the point, and it means a home area moved between machines may present different uid ownership for files outside it.
Where it fits
Good fit:
- A personal laptop where you want your home encrypted independently of the disk
- A machine shared by a few people who should not read each other’s files
- A home area you genuinely want to carry on a USB drive
Poor fit:
- Servers, where accounts are accessed by services and ssh keys without interactive logins
- Multi-user systems backed by a directory service, where SSSD and nsswitch already solve identity
- Anything depending on key-only ssh, unless you move the keys out
Converting an existing account
There is no in-place conversion. The procedure:
# 1. create the new account, with a different name
sudo homectl create alice2 --storage=luks --disk-size=100G --member-of=wheel
# 2. copy the data, preserving everything
sudo homectl unlock alice2
sudo rsync -aAXH --info=progress2 /home/alice/ /home/alice2/
sudo chown -R alice2:alice2 /home/alice2
# 3. verify, by actually using it for a while
# 4. only then remove the old one
sudo userdel alice # keeps /home/alice
rsync -aAXH, because -a alone drops extended attributes and ACLs. Our chattr and xattrs guide covers what that loses, including SELinux labels.
The uid changes. Files owned by the old uid outside the home directory need fixing:
# find them before you delete the old account
sudo find / -xdev -uid "$(id -u alice)" -not -path '/home/*' 2>/dev/null
Keep the old account until the new one is proven. Logging in, ssh, cron, the desktop session, the keyring. That last one specifically, per our keyrings guide, because a copied keyring encrypted with the old password needs re-keying.
Checking state
homectl list
homectl inspect alice
homectl inspect alice --json=pretty | jq '.privileged | keys'
# is it mounted right now
findmnt /home/alice
mount | grep home
# the record as the system sees it
userdbctl user alice
userdbctl --output=json user alice
userdbctl is the broader tool and worth knowing: it queries every user database the system knows about, which on a mixed system means /etc/passwd, homed records and anything from nsswitch.
userdbctl user
userdbctl group
userdbctl services
Frequently Asked Questions
What problem does systemd-homed solve?
It makes a home directory self-describing and portable. The user record lives inside the home area rather than in /etc/passwd, and the area is an encrypted image, so it can move between machines on a USB drive and be unlocked by its own password without the host knowing anything about the account beforehand.
How is this different from encrypting my whole disk with LUKS?
Full disk encryption unlocks once at boot and everything is readable thereafter, including other users home directories. homed encrypts each home separately and unlocks it at login, so a logged out user home stays encrypted while the machine runs. They are complementary rather than alternatives.
Can I still use ssh with a homed account?
Key based login is awkward because authorized_keys lives inside an encrypted home that is locked until the user authenticates, and the key check happens before that. Password authentication works and unlocks the home, so the usual arrangement is password auth for the first login or keys stored outside the home.
What is the difference between luks and subvolume storage?
luks storage is a LUKS encrypted loopback image file, which gives real encryption and is the reason to use homed. subvolume uses a Btrfs subvolume, which gives you per-user quotas and snapshots without encryption. There are also directory and fscrypt options with different trade-offs.
Does systemd-homed work on a server?
It works and is usually the wrong fit. Server accounts are frequently accessed by services or over ssh keys without an interactive login, and homed assumes an authenticating human unlocks the area. Conventional accounts with a directory service are the better arrangement for multi-user servers.
Can I convert an existing user to homed?
Not in place. You create a new homed user and copy the data across, then remove the old account. Plan for the uid changing, which means file ownership outside the home directory needs fixing, and keep the old account until the new one is verified working.