A container with an SSH server and SSH keys which can persist across restarts
  • Shell 51.2%
  • Makefile 25.2%
  • Dockerfile 23.6%
Find a file
Karl E. Jorgensen 872436fd31
All checks were successful
Standard Build / build (push) Successful in 4m48s
explicit platforms for build
2025-12-24 14:49:56 +00:00
.forgejo/workflows explicit platforms for build 2025-12-24 14:49:56 +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 Add support for setting authorized key for root 2025-12-24 13:16:28 +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 Add support for setting authorized key for root 2025-12-24 13:16:28 +00:00
setup-root-ssh Add support for setting authorized key for root 2025-12-24 13:16:28 +00:00
ssh-entrypoint Add support for setting authorized key for root 2025-12-24 13:16:28 +00:00
ssh-healthcheck Add health check 2025-10-07 20:13:29 +01: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 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.

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.

  • 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"]
     ...
    

Health Check

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

If you base your own image on this image, be sure to invoke /ssh-healthcheck as part of your own healthcheck.