Sign in

Mod for openssh-server

Trusted CA

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

arch
amd64
built

Use it#

Set DOCKER_MODS on the openssh-server container and recreate it. The mod is pulled on every start; several mods are separated with |.

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

:openssh-server-trusted-ca always gets the newest build. To stay on this one, pin its tag:

DOCKER_MODS=ghcr.io/linuxserver-playground/mods:openssh-server-trusted-ca-d9d2b3c
services:
  openssh-server:
    image: ghcr.io/linuxserver-playground/openssh-server:latest
    environment:
      - DOCKER_MODS=ghcr.io/linuxserver-playground/mods:openssh-server-trusted-ca

Details#

Mod environment variables

In order to add a certificate authority, you can add your CA’s public keys in one or multiple environment variables:

  • TRUSTED_CA="your_ca_pubkey" to add one CA to the TrustedCA file from text.
  • TRUSTED_CA_URL="https://example.com/trusted_ca.key" to retrieve one or more trusted CA from a URL.
  • TRUSTED_CA_FILE="/mounted_file" to add one or more CA from a file (inside the container’s tree).
  • TRUSTED_CA_DIR="/mounted_dir" to add CAs from the content of a directory (inside the container’s tree).

You can use multiple environment variables at the same time to add different CAs.

Certificates are added/removed from the server when the container is starting, so you will need to restart your container for your change to take effect.

Example

If you want to build your own CA:

# Create temp directory and cd there
cd $(mktemp -d)

# Generate key pairs (x and x.pub)
ssh-keygen -b 4096 -t ed25519 -f myca
ssh-keygen -b 4096 -t ed25519 -f userkey

# Sign users pubkeys (x-cert.pub)
ssh-keygen -s myca -I my_user_certificate_id -n myuser userkey.pub

Notes: -n parameter gives the username principals, it must match the target user (see man 1 ssh-keygen).

services:
  openssh-server:
    image: linuxserver/openssh-server
    environment:
      - DOCKER_MODS=ghcr.io/linuxserver-playground/mods:openssh-server-trusted-ca
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - USER_NAME=myuser
      - TRUSTED_CA_FILE=/pubkey
    volumes:
      - ./myca.pub:/pubkey:ro,z
    ports:
      - 2222:2222

You can then connect using:

ssh -p 2222 -i ./userkey myuser@127.0.0.1

# Or specify the certificate explicitly:
ssh -o CertificateFile=./userkey-cert.pub -p 2222 -i ./userkey myuser@127.0.0.1

Community project

Improve this mod, or make your own

Mods are how LinuxServer images grow without getting heavier: a Dockerfile, a few scripts and a mod.yml. If this one is missing something, or you need one like it for another image, an AI agent in our harness can build and test it with you.

Ask your agent

  • The openssh-server-trusted-ca mod <what is wrong>. Fix it, test it and draft the PR.
  • Make a mod like openssh-server-trusted-ca for <another image>, and test it.

Making a mod Every way to help Get the harness (opens in a new tab)

Source: openssh-server-trusted-ca branch (opens in a new tab). Every mod