|
1 | | -# Rsync - Docker mod for openssh-server |
2 | | - |
3 | | -This mod adds rsync to openssh-server, to be installed/updated during container start. |
4 | | - |
5 | | -In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-rsync` |
6 | | - |
7 | | -If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-rsync|linuxserver/mods:openssh-server-mod2` |
8 | | - |
9 | | -# Mod creation instructions |
10 | | - |
11 | | -* Fork the repo, create a new branch based on the branch `template`. |
12 | | -* Edit the `Dockerfile` for the mod. `Dockerfile.complex` is only an example and included for reference; it should be deleted when done. |
13 | | -* Inspect the `root` folder contents. Edit, add and remove as necessary. |
14 | | -* After all init scripts and services are created, run `find ./ -path "./.git" -prune -o \( -name "run" -o -name "finish" -o -name "check" \) -not -perm -u=x,g=x,o=x -print -exec chmod +x {} +` to fix permissions. |
15 | | -* Edit this readme with pertinent info, delete these instructions. |
16 | | -* Finally edit the `.github/workflows/BuildImage.yml`. Customize the vars for `BASEIMAGE` and `MODNAME`. Set the versioning logic and `MULTI_ARCH` if needed. |
17 | | -* Ask the team to create a new branch named `<baseimagename>-<modname>`. Baseimage should be the name of the image the mod will be applied to. The new branch will be based on the `template` branch. |
18 | | -* Submit PR against the branch created by the team. |
19 | | - |
20 | | - |
21 | | -## Tips and tricks |
22 | | - |
23 | | -* Some images have helpers built in, these images are currently: |
24 | | - * [Openvscode-server](https://github.com/linuxserver/docker-openvscode-server/pull/10/files) |
25 | | - * [Code-server](https://github.com/linuxserver/docker-code-server/pull/95) |
| 1 | +# Trusted CA - Docker mod for openssh-server |
| 2 | + |
| 3 | +This mod allow the configuration of the `TrustedUserCAKeys` directive, which allows ssh authentication using certificates. |
| 4 | + |
| 5 | +In openssh-server docker arguments, set an environment variable `DOCKER_MODS=linuxserver/mods:openssh-server-trusted-ca` |
| 6 | + |
| 7 | +If adding multiple mods, enter them in an array separated by `|`, such as `DOCKER_MODS=linuxserver/mods:openssh-server-trusted-ca|linuxserver/mods:openssh-server-mod2` |
| 8 | + |
| 9 | +## Mod environment variables |
| 10 | +In order to add a certificate authority, you can add your CA's public keys in one or multiple environment variables: |
| 11 | +* `TRUSTED_CA="your_ca_pubkey"` to add one CA to the TrustedCA file from text. |
| 12 | +* `TRUSTED_CA_URL="https://example.com/trusted_ca.key"` to retrieve one or more trusted CA from a URL. |
| 13 | +* `TRUSTED_CA_FILE="/mounted_file"` to add one or more CA from a file (inside the container's tree). |
| 14 | +* `TRUSTED_CA_DIR="/mounted_dir"` to add CAs from the content of a directory (inside the container's tree). |
| 15 | + |
| 16 | +You can use multiple environment variables at the same time to add different CAs. |
| 17 | + |
| 18 | +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. |
| 19 | + |
| 20 | +# Example |
| 21 | +If you want to build your own CA: |
| 22 | +``` |
| 23 | +# Create temp directory and cd there |
| 24 | +cd $(mktemp -d) |
| 25 | +
|
| 26 | +# Generate key pairs (x and x.pub) |
| 27 | +ssh-keygen -b 4096 -t ed25519 -f myca |
| 28 | +ssh-keygen -b 4096 -t ed25519 -f userkey |
| 29 | +
|
| 30 | +# Sign users pubkeys (x-cert.pub) |
| 31 | +ssh-keygen -s myca -I my_user_certificate_id -n myuser userkey.pub |
| 32 | +``` |
| 33 | + |
| 34 | +Notes: `-n` parameter gives the username principals, it must match the target user (see `man 1 ssh-keygen`). |
| 35 | + |
| 36 | +``` |
| 37 | +services: |
| 38 | + openssh-server: |
| 39 | + image: linuxserver/openssh-server |
| 40 | + environment: |
| 41 | + - DOCKER_MODS=linuxserver/mods:openssh-server-trusted-ca |
| 42 | + - PUID=1000 |
| 43 | + - PGID=1000 |
| 44 | + - TZ=Etc/UTC |
| 45 | + - USER_NAME=myuser |
| 46 | + - TRUSTED_CA_FILE=/pubkey |
| 47 | + volumes: |
| 48 | + - ./myca.pub:/pubkey:ro,z |
| 49 | + ports: |
| 50 | + - 2222:2222 |
| 51 | +``` |
| 52 | + |
| 53 | +You can then connect using: |
| 54 | +``` |
| 55 | +ssh -p 2222 -i ./userkey myuser@127.0.0.1 |
| 56 | +
|
| 57 | +# Or specify the certificate explicitly: |
| 58 | +ssh -o CertificateFile=./userkey-cert.pub -p 2222 -i ./userkey myuser@127.0.0.1 |
| 59 | +``` |
0 commit comments