- Shell 72.5%
- Dockerfile 27.5%
| .forgejo/workflows | ||
| tests | ||
| .hadolint.yaml | ||
| Containerfile | ||
| entrypoint.sh | ||
| README.md | ||
| renovate.json | ||
| sshd_config | ||
docker-rrsync
An OpenSSH server that gives read-only rsync access to one directory, and nothing else.
The image is rebuilt weekly from debian:stable-slim and published at
guardianproject.dev/sr2/docker-rrsync:latest.
Features
- One user,
rrsync, authenticating with a public key only. - Every session runs
rrsync -ro /srv/rrsync, so a client can read from/srv/rrsyncand cannot write, run a shell or command, use sftp, or forward anything.
rrsync refuses -L (copy-links), so a client cannot follow a symlink on the
server.
rsync -rlt -e 'ssh -p 2222' rrsync@example.org:./ local/
Hardening
sshd_config follows section 5.1 of the CIS Debian Linux 13 Benchmark v1.0.0.
The ciphers, MACs and key exchange algorithms are allow-lists that drop
everything the benchmark removes and are narrowed further until ssh-audit
reports no warnings: AES-GCM and AES-CTR, SHA-2 encrypt-then-MAC, and hybrid
post-quantum key exchange only. Clients need OpenSSH 8.5 or later.
CI starts the built image and runs two syver (goss) specs against it:
tests/goss-server.yml, inside the container: section 5.1 of ansible-lockdown/DEBIAN13-CIS-AUDIT with its own vars, plus checks for key-only login, the forced rrsync command and socket activation support;tests/goss-client.yml, from a client container: ssh-audit, a directory fetch from the server and from a second, socket-activated sshd, and refusal of uploads,-L, commands, sftp, root and password logins.
The audit runs some checks through sudo, so the test adds a pass-through
sudo to the container under test. The published image has no sudo.
Run the same tests locally with tests/run.sh IMAGE SYVER AUDIT: see the
script for the arguments.
Usage
| Path | Purpose |
|---|---|
/srv/rrsync |
The directory to export. Mount it read-only. |
/etc/rrsync |
Holds authorized_keys, the keys allowed to log in as rrsync. Mount the directory read-only rather than the file, so a replaced file is seen. Both must be owned by root inside the container and not group or world writable. |
/etc/ssh/keys |
Host keys, generated on first start. Keep it on a volume so the fingerprints don't change. |
The server listens on port 2222. Logs go to stderr.
podman run -d --name rrsync \
-p 2222:2222 \
-v /path/to/export:/srv/rrsync:ro \
-v /path/to/auth:/etc/rrsync:ro \
-v rrsync-hostkeys:/etc/ssh/keys \
guardianproject.dev/sr2/docker-rrsync:latest
Socket activation
Debian's sshd accepts a listening socket from systemd (LISTEN_FDS), and
Podman passes one into the container from a socket unit. The container then
needs no network at all (Network=none), and sshd sees each client's real
address. sshd ignores Port when it is handed a socket.
# rrsync.socket
[Socket]
ListenStream=2222
BindIPv6Only=both
# rrsync.container
[Container]
Image=guardianproject.dev/sr2/docker-rrsync:latest
Network=none
...
The rrsync user is UID 2000 in the container. It only needs read access to
the exported files.
pam_loginuid is made optional in the image, because setting the login UID
needs CAP_AUDIT_CONTROL, which a rootless container doesn't have.