A container with a user configured, an SSH server and rsync installed
  • Shell 68.8%
  • Makefile 20.3%
  • Dockerfile 10.9%
Find a file
Karl E. Jorgensen 6c3c1de56d
All checks were successful
Docker Build / build (push) Successful in 2m59s
Now based on code.jorgensen.org.uk/karl/ssh:v0.1.7
2026-02-03 23:04:55 +00:00
.forgejo/workflows Try out new version of ssh container 2026-02-03 21:57:44 +00:00
.dockerignore Feature: Add support for creating a user 2026-01-04 01:56:29 +00:00
Dockerfile Now based on code.jorgensen.org.uk/karl/ssh:v0.1.7 2026-02-03 23:04:55 +00:00
Makefile Feature: slightly better dev testing 2026-01-04 13:05:46 +00:00
README.md Try out new version of ssh container 2026-02-03 21:57:44 +00:00
rsync-entrypoint Bugfix: setup-rsync -> rsync-setup 2026-02-03 22:50:17 +00:00
rsync-healthcheck Try out new version of ssh container 2026-02-03 21:57:44 +00:00
rsync-setup Bugfix: setup-rsync -> rsync-setup 2026-02-03 22:50:17 +00:00

rsync

A simple container which provides an SSH server and has rsync & unison installed.

This is based on https://code.jorgensen.org.uk/karl/ssh-container - see the README.md there for details about how to configure SSH keys for the root user.

This is intended as a simple utility to allow users to update files in e.g. a volume.

For most use cases we want a use a non-root user for access. This is controlled through environment variables:

  • USER_NAME specifies the username to be created. If this is not set, no user will be created.

  • USER_ID (optional) the numeric ID of the user. If not set, the container will choose a UID. Note that a container-chosen UID is not guaranteed to be consistent across invocations or container versions.

  • HOMEDIR (optional) The $HOME directory of the user. If not set, a suitable default will be used.

  • USER_SHELL (optional) - the user's shell.

  • GROUP_NAME (optional) name of the user's primary group

  • GROUP_ID (optional) numeric ID of GROUP_NAME

  • USER_COMMENT (optional) the comment (a.k.a. GECOS) information for the user.

  • USER_PUBKEY: The user's public key. This will be what ends up in the user's .ssh/authorized_keys file. This may contain newlines, which will allow for multiple keys.

    To limit the user to running rsync (or some other command), this can be done using the usual SSH facilities - see the man page for SSHD(8) - the AUTHORIZED_KEYS FILE FORMAT section.

NOTE: The user will be configured to not allow password-based logins. So setting USER_PUBKEY is quite essential.

Ports

The container will expose an SSH server on port 22.

Volumes

To persist SSH keys across container restarts: mount a persistent volume on /srv/ssh.

Health Check

The container provides a simple health check with the command /rsync-healthcheck.

Building on This

If you build a container based on this image, be sure to do one of:

  • Do not override the Dockerfile ENTRYPOINT, thus leaving the ENTRYPOINT from this container in effect.

  • Early in your entrypoint script: make a call to /rsync-setup. Be sure to to handle a non-zero exit code from rsync-setup correctly - e.g.:

     #!/bin/sh
     set -e
     /rsync-setup
     # Do your own stuff here
    

    It is also recommended that you provide your setup script (e.g. named /mycontainer-setup) and make it available for users who want to build on top of your container - probably with instructions similar to this in your own README.md file.

  • Make your Dockerfile ENTRYPOINT a call to /rsync-entrypoint giving the path to your own entrypoint (and any parameters it needs) as parameters - e.g.:

     # Dockerfile
     ...
     COPY mycontainer-entrypoint /mycontainer-entrypoint
     ENTRYPOINT ["/rsync-entrypoint", "/mycontainer-entrypoint", "foo", "bar"]
     ...
    

Also: be sure to invoke /rsync-healthcheck as part of your own healthcheck.