A container with an SSH server and SSH keys which can persist across restarts
  • Shell 52.5%
  • Makefile 25.2%
  • Dockerfile 22.3%
Find a file
Karl E. Jorgensen d3b2d4f12f
All checks were successful
Standard Build / build (push) Successful in 3m29s
Now based on code.jorgensen.org.uk/debian-base:13.3-2
2026-02-03 21:46:46 +00:00
.forgejo/workflows Generalise selection of platforms 2026-02-03 16:53:27 +00:00
.dockerignore First try with forgejo actions! 2025-12-23 22:27:05 +00:00
.gitignore Update Makefile to allow local testing 2025-10-07 19:12:30 +01:00
10-ssh-container.conf Rename ssh configuration drop-in file. 2025-10-07 19:17:32 +01:00
Dockerfile Now based on code.jorgensen.org.uk/debian-base:13.3-2 2026-02-03 21:46:46 +00:00
LICENSE Add docker image labels and license 2025-10-07 22:22:41 +01:00
Makefile Add support for setting authorized key for root 2025-12-24 13:16:28 +00:00
README.md Tidyup 2026-02-03 16:49:29 +00:00
setup-root-ssh Add support for setting authorized key for root 2025-12-24 13:16:28 +00:00
ssh-entrypoint Rework entrypoint 2026-02-03 14:02:09 +00:00
ssh-healthcheck Add health check 2025-10-07 20:13:29 +01:00
ssh-setup Rework entrypoint 2026-02-03 14:02:09 +00:00
update-ssh-keys Update Makefile to allow local testing 2025-10-07 19:12:30 +01:00

SSH Container

A simple container which runs SSH upon startup.

It will persist SSH host keys in /srv/ssh/ - thus allowing the container to have a persistent SSH "identity" across startups.

Note that this container does not set up any users.

If the environment variable ROOT_AUTHORIZED_KEY is set, this will be added to /root/.ssh/authorized_keys.

It does make some minor tweaks to the Debian default SSH configuration to enforce that root can only login using a key (password authentication is not allowed) - see 10-ssh-container.conf for details.

The container's ENTRYPOINT (technically /ssh-setup) will generate keys as needed (and persist them to /srv/ssh/) and start a SSH daemon before launching the given command. If no command is given, it will default to /bin/bash.

Ports

The container will expose an SSH server on port 22.

Volumes

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

Health Check

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

Building on This

If you build a container based on this image, be sure to do exactly 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 /ssh-setup. Be sure to to handle a non-zero exit code from ssh-setup correctly - e.g.:

     #!/bin/sh
     set -e
     /ssh-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 /ssh-entrypoint giving the path to your own entrypoint (and any parameters it needs) as parameters - e.g.:

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

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