Skip to content

Commit bf83f8a

Browse files
authored
Merge pull request #460 from cgwalters/docs-users-ssh-tmpfiles
users-and-groups: Explain patterns for tmpfs /home more
2 parents 7554f10 + 801cc39 commit bf83f8a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

docs/src/building/users-and-groups.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,6 @@ and `/home`. The choice for how these work is up to the base image, but
140140
a common default for generic base images is to have both be machine-local persistent state.
141141
In this model `/home` would be a symlink to `/var/home/someuser`.
142142

143-
But it is also valid to default to having e.g. `/home` be a `tmpfs`
144-
to ensure user data is cleaned up across reboots (and this pairs particularly
145-
well with a transient `/etc` as well).
146-
147143
#### Injecting users and SSH keys via at system provisioning time
148144

149145
For base images where `/etc` and `/var` are configured to persist by default, it
@@ -163,6 +159,26 @@ It is intended that these flows work equivalently in a bootc-compatible
163159
system, to support users directly installing "generic" base images, without
164160
requiring changes to the tools above.
165161

162+
#### Transient home directories
163+
164+
Many operating system deployments will want to minimize persistent,
165+
mutable and executable state - and user home directories are that
166+
167+
But it is also valid to default to having e.g. `/home` be a `tmpfs`
168+
to ensure user data is cleaned up across reboots (and this pairs particularly
169+
well with a transient `/etc` as well):
170+
171+
In order to set up the user's home directory to e.g. inject SSH `authorized_keys`
172+
or other files, a good approach is to use systemd `tmpfiles.d` snippets:
173+
174+
```
175+
f~ /home/someuser/.ssh/authorized_keys 600 someuser someuser - <base64 encoded data>
176+
```
177+
which can be embedded in the image as `/usr/lib/tmpfiles.d/someuser-keys.conf`.
178+
179+
Or a service embedded in the image can fetch keys from the network and write
180+
them; this is the pattern used by cloud-init and [afterburn](https://github.com/coreos/afterburn).
181+
166182
### UID/GID drift
167183

168184
Ultimately the `/etc/passwd` and similar files are a mapping

0 commit comments

Comments
 (0)