Sign in

openssh-server

10.3_p1-r2-ls8

Openssh-server is a sandboxed environment that allows ssh access without giving keys to the entire server. Giving ssh access via private key often means giving full access to the server. This container creates a limited and sandboxed environment that others can ssh into. The users only have access to the folders mapped and the processes running inside this container.

docker pull ghcr.io/linuxserver-playground/openssh-server:latest

Quick start · configure#

Pick the optional settings and mods you want, set your paths, ports and values, then copy the result.

Image
Identity

The user the application runs as and its timezone.

Required
Contains all relevant configuration files.
ssh port
Optional settings11

Tick what you need; it is added to every output with its value.

Mods

5 for openssh-server, 0 universal mods suggested for it, and 13 other universal mods. Ticked mods join one DOCKER_MODS value in the order you tick them.

---
services:
  openssh-server:
    image: ghcr.io/linuxserver-playground/openssh-server:latest
    container_name: openssh-server
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
    volumes:
      - /path/to/openssh-server/config:/config
    ports:
      - 2222:2222
    restart: unless-stopped

Required settings only. Tick optional settings and mods to add them.

  • Replace the /path/to folders with real folders on your host; they are created if missing.

Install on …

Adding a store to your platform

Version tags#

TagLatest buildBuiltTests
:latestStable releasesbranch master · stable10.3_p1-r2-ls8amd64 · arm64 passed

Architectures#

Pulling :latest picks the right one for your host automatically.

  • x86_64amd64-latest
  • arm64arm64v8-latest

Inside the latest image#

ghcr.io/linuxserver-playground/openssh-server:10.3_p1-r2-ls8

Explore this build
Base image
ghcr.io/linuxserver-playground/baseimage-alpine:3.24
Upstream version
10.3_p1-r2
amd64 compressed
15.1 MB · 9 layers
arm64 compressed
16.0 MB · 9 layers
amd64 packages
62 · Alpine Linux v3.24
arm64 packages
62 · Alpine Linux v3.24
Tests
passed
Built
Reason
weekly package check

In the fleet#

Live branches, their latest release, upstream version and next scheduled check.

openssh-server on the fleet board

live branchesloading…

Branch → tagLast buildReleasedUpstreamDriftNext checkFlags
master → :latestsuccess
10.3_p1-r2
? unknown––

Application setup#

If PUBLIC_KEY or PUBLIC_KEY_FILE, or PUBLIC_KEY_DIR variables are set, the specified keys will automatically be added to authorized_keys. If not, the keys can manually be added to /config/.ssh/authorized_keys and the container should be restarted. Removing PUBLIC_KEY or PUBLIC_KEY_FILE variables from docker run environment variables will not remove the keys from authorized_keys. PUBLIC_KEY_FILE and PUBLIC_KEY_DIR can be used with docker secrets.

We provide the ability to set and allow password based access via the PASSWORD_ACCESS and USER_PASSWORD variables, though we as an organization discourage using password auth for public facing ssh endpoints.

Connect to server via ssh -i /path/to/private/key -p PORT USER_NAME@SERVERIP

Setting SUDO_ACCESS to true by itself will allow passwordless sudo. USER_PASSWORD and USER_PASSWORD_FILE allow setting an optional sudo password.

The users only have access to the folders mapped and the processes running inside this container. Add any volume mappings you like for the users to have access to. To install packages or services for users to access, use the LinuxServer container customization methods described in this blog article.

Sample use case is when a server admin would like to have automated incoming backups from a remote server to the local server, but they might not want all the other admins of the remote server to have full access to the local server. This container can be set up with a mounted folder for incoming backups, and rsync installed via LinuxServer container customization described above, so that the incoming backups can proceed, but remote server and its admins’ access would be limited to the backup folder.

It is also possible to run multiple copies of this container with different ports mapped, different folders mounted and access to different private keys for compartmentalized access.

TIPS

You can volume map your own text file to /etc/motd to override the message displayed upon connection. You can optionally set the docker argument hostname

Parameters#

Ports#
PortFunctionRequired
2222:2222ssh portrequired
Environment variables#
VariableFunctionRequired
PUID=1000User IDrequired
PGID=1000Group IDrequired
TZ=Etc/UTCTimezonerequired
PUBLIC_KEY=yourpublickeyOptional ssh public key, which will automatically be added to authorized_keys.optional
PUBLIC_KEY_FILE=/path/to/fileOptionally specify a file containing the public key (works with docker secrets).optional
PUBLIC_KEY_DIR=/path/to/directory/containing/_only_/pubkeysOptionally specify a directory containing the public keys (works with docker secrets).optional
PUBLIC_KEY_URL=https://github.com/username.keysOptionally specify a URL containing the public key.optional
SUDO_ACCESS=falseSet to true to allow linuxserver.io, the ssh user, sudo access. Without USER_PASSWORD set, this will allow passwordless sudo access.optional
PASSWORD_ACCESS=falseSet to true to allow user/password ssh access. You will want to set USER_PASSWORD or USER_PASSWORD_FILE as well.optional
USER_PASSWORD=passwordOptionally set a sudo password for linuxserver.io, the ssh user. If this or USER_PASSWORD_FILE are not set but SUDO_ACCESS is set to true, the user will have passwordless sudo access.optional
USER_PASSWORD_FILE=/path/to/fileOptionally specify a file that contains the password. This setting supersedes the USER_PASSWORD option (works with docker secrets).optional
USER_NAME=linuxserver.ioOptionally specify a user name (Default:linuxserver.io)optional
LOG_STDOUT=Set to true to log to stdout instead of file.optional
Volumes#
PathFunctionRequired
/configContains all relevant configuration files.required
Other settings#
SettingFunctionRequired
hostname: openssh-serverOptionally the hostname can be defined.optional

Key Generation#

This container has a helper script to generate an ssh private/public key. In order to generate a key please run:

docker run --rm -it --entrypoint /keygen.sh linuxserver/openssh-server

Then simply follow the prompts. The keys generated by this script are only displayed on your console output, so make sure to save them somewhere after generation.

Environment variables from files (Docker secrets)#

You can set any environment variable from a file by using a special prepend FILE__.

As an example:

-e FILE__MYVAR=/run/secrets/mysecretvariable

Will set the environment variable MYVAR based on the contents of the /run/secrets/mysecretvariable file.

Umask for running applications#

For all of our images we provide the ability to override the default umask settings for services started within the containers using the optional -e UMASK=022 setting. Keep in mind umask is not chmod it subtracts from permissions based on it’s value it does not add. Please read up here before asking for support.

User / Group Identifiers#

When using volumes (-v flags), permissions issues can arise between the host OS and the container, we avoid this issue by allowing you to specify the user PUID and group PGID.

Ensure any volume directories on the host are owned by the same user you specify and any permissions issues will vanish like magic.

In this instance PUID=1000 and PGID=1000, to find yours use id your_user as below:

id your_user

Example output:

uid=1000(your_user) gid=1000(your_user) groups=1000(your_user)

Updating Info#

Most of our images are static, versioned, and require an image update and container recreation to update the app inside. With some exceptions (noted in the relevant readme.md), we do not recommend or support updating apps inside the container. Please consult the Application Setup section above to see if it is recommended for the image.

Below are the instructions for updating containers:

Via Docker Compose

  • Update images:

    • All images:

      docker-compose pull
    • Single image:

      docker-compose pull openssh-server
  • Update containers:

    • All containers:

      docker-compose up -d
    • Single container:

      docker-compose up -d openssh-server
  • You can also remove the old dangling images:

    docker image prune

Via Docker Run

  • Update the image:

    docker pull ghcr.io/linuxserver-playground/openssh-server:latest
  • Stop the running container:

    docker stop openssh-server
  • Delete the container:

    docker rm openssh-server
  • Recreate a new container with the same docker run parameters as instructed above (if mapped correctly to a host folder, your /config folder and settings will be preserved)

  • You can also remove the old dangling images:

    docker image prune

Image Update Notifications - Diun (Docker Image Update Notifier)

Tip

We recommend Diun for update notifications. Other tools that automatically update containers unattended are not recommended or supported.

Building locally#

If you want to make local modifications to these images for development purposes or just to customize the logic:

git clone https://github.com/linuxserver-playground/docker-openssh-server.git
cd docker-openssh-server
docker build \
  --no-cache \
  --pull \
  -t ghcr.io/linuxserver-playground/openssh-server:latest .

The ARM variants can be built on x86_64 hardware and vice versa using ghcr.io/linuxserver/qemu-static

docker run --rm --privileged ghcr.io/linuxserver/qemu-static --reset

Once registered you can define the dockerfile to use with -f Dockerfile.aarch64.

Every push builds and tests the image with the shared workflow in linuxserver-playground/workflows; every build’s tests, screenshots and package changes are on the image’s builds on the website.

Builds#

The newest five builds per branch, each with its CI report; 4 older releases are on GitHub, listed below.

TagBuiltReasonChangeResultSize
10.3_p1-r2-ls8master · 449f1270weekly package checkbasesuccess15.1 MB amd6416.0 MB arm64
10.3_p1-r2-ls7master · 955f602fweekly package checkbasesuccess15.1 MB amd6416.0 MB arm64
10.3_p1-r2-ls6master · 0de91b52weekly package checkbasesuccess15.1 MB amd6416.0 MB arm64
10.3_p1-r2-ls5master · 435fee2aupstream checkmixedsuccess15.1 MB amd6416.0 MB arm64
10.3_p1-r1-ls5master · 214b72bbpush to the branchlinuxserversuccess15.1 MB amd6416.0 MB arm64
Older releases4Release, run record and run on GitHub

Mods#

Add a mod with DOCKER_MODS=<image>; separate several with |.

All mods for openssh-server
  • autossh

    This mod adds autossh to openssh-server, to be installed/updated during container start.

    ghcr.io/linuxserver-playground/mods:openssh-server-autossh
  • Git

    This mod adds git to openssh-server, to be installed/updated during container start.

    ghcr.io/linuxserver-playground/mods:openssh-server-git
  • Rsync

    This mod adds rsync to openssh-server, to be installed/updated during container start.

    ghcr.io/linuxserver-playground/mods:openssh-server-rsync
  • SSH-Tunnel

    This mod adds ssh tunnelling to openssh-server, by enabling tcp forwarding during container start.

    ghcr.io/linuxserver-playground/mods:openssh-server-ssh-tunnel
  • Trusted CA

    This mod allow the configuration of the TrustedUserCAKeys directive, which allows ssh authentication using certificates.

    ghcr.io/linuxserver-playground/mods:openssh-server-trusted-ca

Plus 13 other universal mods that work with every image.

Changelog#

  1. Rebase to Alpine 3.24.

  2. Rebase to Alpine 3.23.

  3. Rebase to Alpine 3.22.

  4. Add support for sshd_config.d

  5. Rebase to Alpine 3.21.

  6. Move sshd_config to /config/sshd/sshd_config.

  7. Rebase to Alpine 3.20.

  8. Display the SSH host public keys every time the container starts.

18 earlier entries
  1. Rebase to Alpine 3.19.
  2. Rebase to Alpine 3.18, deprecate armhf. As announced here (opens in a new tab)
  3. Rebase to Alpine 3.17.
  4. Fix wrong behavior of password/passwordless sudo
  5. Rebase to Alpine 3.16, migrate to s6v3.
  6. add netcat-openbsd with support for proxies.
  7. Fix service perms to comply with upgrade to s6 v3.
  8. Rebase to alpine 3.15.
  9. Add PUBLIC_KEY_URL option
  10. Rebasing to alpine 3.14. Add support for PAM.
  11. Rebasing to alpine 3.13. Add openssh-client for scp.
  12. Implement s6-log for openssh, which adds local timestamps to logs and can be used with a log parser like fail2ban.
  13. Set umask for sftp.
  14. Rebasing to alpine 3.12.
  15. Add key generation script.
  16. Add openssh-sftp-server.
  17. Rebasing to alpine 3.11.
  18. Initial Release.

Support#

Questions about running openssh-server? Start with the documentation and the community; open an issue for bugs.

  • Shell access whilst the container is running:

    docker exec -it openssh-server /bin/bash
  • To monitor the logs of the container in realtime:

    docker logs -f openssh-server
  • Container version number:

    docker inspect -f '{{ index .Config.Labels "build_version" }}' openssh-server
  • Image version number:

    docker inspect -f '{{ index .Config.Labels "build_version" }}' ghcr.io/linuxserver-playground/openssh-server:latest

Community project

Improve openssh-server

This image is kept up by volunteers, and you can be one of them. You don't need to know how the pipeline works: point an AI agent at the harness and describe what you want. It reproduces the problem in your Docker, tests the change and drafts the pull request for you to check.

Ask your agent

  • Something is wrong with the openssh-server image: <what you saw>. Reproduce it, fix it and draft the PR.
  • Add <package> to the openssh-server image, test it and draft the PR.
  • Make a mod for openssh-server that <what you need>, and test it.

Contributing an image Every way to help Get the harness (opens in a new tab)

Related

Browse all

doublecommander

03760012-ls11

Double Commander is a free cross platform open source file manager with two panels side by side. It is inspired by Total Commander and features some new ideas.

0 GitHub starsselkiesarm64

hishtory-server

v0.335-ls7

hiSHtory is a better shell history. It stores your shell history in context (what directory you ran the command in, whether it succeeded or failed, how long it took, etc). This is all stored locally and end-to-end encrypted for syncing to to all your other computers.

0 GitHub starsalpinearm64

ldap-auth

3.4.8-ls7

Ldap-auth software is for authenticating users who request protected resources from servers proxied by nginx. It includes a daemon (ldap-auth) that communicates with an authentication server, and a webserver daemon that generates an authentication cookie based on the user’s credentials. The daemons are written in Python for use with a Lightweight Directory Access Protocol (LDAP) authentication server (OpenLDAP or Microsoft Windows Active Directory 2003 and 2012).

0 GitHub starsalpinearm64

netbox

v4.7.6-ls12

Netbox is an IP address management (IPAM) and data center infrastructure management (DCIM) tool. Initially conceived by the network engineering team at DigitalOcean, NetBox was developed specifically to address the needs of network and infrastructure engineers. It is intended to function as a domain-specific source of truth for network operations.

0 GitHub starsalpinearm64