Repository navigation
SSH persistence guide
This guide explains how to prepare your Denon PRIME 4 filesystem so that SSH access persists across reboots and firmware upgrades on Engine OS 5.x (AZ01, Yocto-based).
The Denon PRIME 4 uses overlayfs to separate persistent user data from the read-only root filesystem. /etc and /var are each mounted as a real OverlayFS union (confirmed from the etc.mount/var.mount unit definitions):
[Mount]
What=overlay
Where=/etc
Type=overlay
Options=lowerdir=/etc,upperdir=/data/system/etc/overlay,workdir=/data/system/etc/.work
(and the equivalent for /var, with upperdir=/data/system/var/overlay.)
The rest of the filesystem, including /root, /usr and /home, is mounted read-only (/dev/root / auto ro in /etc/fstab) and is fully replaced on every firmware update. Only /data (and therefore the two overlay upper directories) is persistent.
graph TD
A[Boot Process] --> B[Mount Root Filesystem read-only]
A --> C[Mount data Partition]
B --> D[etc - base config files]
B --> E[var - base variable data]
C --> F[data/system/etc/overlay]
C --> G[data/system/var/overlay]
D --> H[overlayfs Merge]
E --> I[overlayfs Merge]
F --> H
G --> I
H --> J[etc - merged view]
I --> K[var - merged view]
style F fill:#90EE90
style G fill:#90EE90
style D fill:#FFB6C1
style E fill:#FFB6C1
This means:
- ✅ Anything placed under
/data/system/etc/overlay/or/data/system/var/overlay/survives reboots and firmware upgrades (as long as/dataitself isn't reformatted). - ❌ Anything written to the base rootfs (
/etc/...,/var/...,/root/...,/usr/...) at runtime is lost on reboot, because the underlying rootfs is mounted read-only and gets replaced wholesale on every firmware update anyway.
/etc/az01/overlayfs.conf is a systemd-tmpfiles config, run by overlayfs-setup.service (systemd-tmpfiles --create --remove /etc/az01/overlayfs.conf) before etc.mount/var.mount are mounted, i.e. on every single boot:
r /data/system/etc/overlay/group - - - -
r /data/system/etc/overlay/gshadow - - - -
r /data/system/etc/overlay/passwd - - - -
r /data/system/etc/overlay/shadow - - - -
R /data/system/etc/overlay/ssh - - - -
r deletes a single file; R deletes a whole directory tree, recursively. This means:
- Anything under
/data/system/etc/overlay/ssh/— which is where the rootfs-level/etc/ssh/sshd_config.d/and/etc/ssh/authorized_keys.d/override paths would naturally land — is deleted before the overlay is even mounted, every boot. -
/etc/passwd,/etc/shadow,/etc/groupand/etc/gshadowoverrides are deleted the same way, so setting a root password via the overlay does not work either.
There's also R /data/system/var/overlay/run (clears stale runtime state each boot, standard practice) — this only affects the run subdirectory under the /var overlay, nothing else.
Anything you persist for SSH must avoid /data/system/etc/overlay/ssh/* and the four auth files listed above. Everything else under /data/system/etc/overlay/ and /data/system/var/overlay/ (aside from run) is left alone.
Stock 5.x firmware already ships (baked directly into the rootfs, not the overlay, so it is not affected by the wipe list):
-
/etc/ssh/sshd_config.d/10-az0x.conf:i.e. root login via SSH key is already permitted; only password/interactive login is disallowed. NoHostKey /etc/ssh/ssh_host_ed25519_key HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-ed25519 PermitRootLogin prohibit-password PasswordAuthentication no KbdInteractiveAuthentication nosshd_configoverride is required. - An empty
/root/.ssh/directory, but noauthorized_keys— so nobody can actually log in yet. -
sshd.serviceexists but is not enabled (/usr/lib/systemd/system/multi-user.target.wants/only containsdbus.service,getty.target,systemd-ask-password-wall.path,systemd-update-utmp-runlevel.service— nosshd.service).
So the only two things that actually need to persist are: (1) enabling sshd.service, and (2) supplying an authorized_keys file for root from a path that isn't on the wipe list.
You need existing shell access (e.g. from a modified 4.x firmware with SSH already enabled, or a serial/UART console) to run these commands once.
Create the systemd override symlink at the standard /etc/systemd/system/ unit-search path (not /etc/lib/..., which systemd never scans):
mkdir -p /data/system/etc/overlay/systemd/system/multi-user.target.wants
ln -s /usr/lib/systemd/system/sshd.service \
/data/system/etc/overlay/systemd/system/multi-user.target.wants/sshd.serviceThis is identical in effect to what systemctl enable sshd.service would create, and after the /etc overlay merge it appears at /etc/systemd/system/multi-user.target.wants/sshd.service — the same location systemd's own persistent unit overrides live in.
Store the key under the /var overlay instead of /etc/ssh/authorized_keys.d/ (which is wiped):
mkdir -p /data/system/var/overlay/ssh-keys/root
chmod 700 /data/system/var/overlay/ssh-keys/root
# Paste your public key content into the file below, one key per line:
cat > /data/system/var/overlay/ssh-keys/root/authorized_keys << 'EOF'
ssh-ed25519 AAAA... your-key-comment
EOF
chmod 600 /data/system/var/overlay/ssh-keys/root/authorized_keysThis merges to /var/ssh-keys/root/authorized_keys after the /var overlay is mounted.
Override AuthorizedKeysFile via SSHD_OPTS in /etc/default/ssh (also not on the wipe list; sshd.service sources it via EnvironmentFile=-/etc/default/ssh):
mkdir -p /data/system/etc/overlay/default
cat > /data/system/etc/overlay/default/ssh << 'EOF'
SYSCONFDIR=${SYSCONFDIR:-/etc/ssh}
SSHD_OPTS="-o AuthorizedKeysFile=/var/ssh-keys/root/authorized_keys"
EOFrebootAfter reboot:
ssh root@<device-hostname-or-ip>You should get a root shell — no password prompt, since PasswordAuthentication no is already the stock default and we're relying entirely on pubkey auth.
# Confirm the overlay is mounted
mount | grep overlay
# Confirm sshd.service is enabled and running
systemctl is-enabled sshd
systemctl status sshd
# Confirm the key file merged correctly
cat /var/ssh-keys/root/authorized_keys
# Confirm the env override merged correctly
cat /etc/default/sshThis means the network stack is up but nothing is listening on port 22 — almost always sshd.service is not enabled. Check:
systemctl is-enabled sshd # should print "enabled"
ls -l /etc/systemd/system/multi-user.target.wants/ # should list sshd.serviceIf the symlink is missing after a reboot, double-check it was created at /data/system/etc/overlay/systemd/system/multi-user.target.wants/sshd.service (not .../lib/systemd/system/...) — that's the exact mistake that causes this symptom.
- Confirm
/var/ssh-keys/root/authorized_keysexists after the overlay merge and contains your public key on its own line. - Confirm
/etc/default/sshmerged correctly andSSHD_OPTSis being picked up (systemctl show sshd.service | grep Environment). - Confirm file permissions:
chmod 700onssh-keys/root,chmod 600on theauthorized_keysfile itself, owned by root.
If files placed under /data/system/etc/overlay/ssh/... or the four auth files (passwd, shadow, group, gshadow) vanish after every reboot, that's expected — see Denon's Active Wipe List above. Move the content to a path outside that list (as this guide now does).
-
SSH key authentication only. Stock firmware already disables password and keyboard-interactive authentication (
PasswordAuthentication no,KbdInteractiveAuthentication no) — this guide does not change that, and there is no working path to persist a root password anyway (/etc/shadowoverrides are wiped every boot). - Treat
/var/ssh-keys/root/authorized_keyslike any otherauthorized_keysfile: keep its permissions tight (700/600) and only add keys you trust with full root access. - Firmware upgrades within the 5.x line (e.g. 5.0.0 → 5.0.3) do not reformat
/data, so this setup persists across them. Major version changes (e.g. downgrading to/from 4.x Buildroot-based firmware) use a completely different init system and overlay layout, so this configuration does not carry over across that boundary and must be reapplied.
- Engine OS 5.x AZ01 Notes - PR with SSH enablement findings on PRIME GO 5.0.1
- Firmware Image Structure - Complete firmware documentation