Skip to content

Commit 113c8a6

Browse files
authored
Merge pull request #1137 from Koalab99/openssh-server-trusted-ca
openssh-server: trusted-ca Initial commit
2 parents 6360fcf + 458dba3 commit 113c8a6

23 files changed

Lines changed: 119 additions & 112 deletions

File tree

.github/workflows/BuildImage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ on:
1212
env:
1313
GITHUB_REPO: "linuxserver/docker-mods" #don't modify
1414
ENDPOINT: "linuxserver/mods" #don't modify
15-
BASEIMAGE: "replace_baseimage" #replace
16-
MODNAME: "replace_modname" #replace
15+
BASEIMAGE: "openssh-server" #replace
16+
MODNAME: "trusted-ca" #replace
1717
MOD_VERSION: ${{ inputs.mod_version }} #don't modify
18-
MULTI_ARCH: "true" #set to false if not needed
18+
MULTI_ARCH: "false" #set to false if not needed
1919

2020
jobs:
2121
set-vars:

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
FROM scratch
44

5-
LABEL maintainer="username"
5+
LABEL maintainer="Koalab99"
66

77
# copy local files
88
COPY root/ /

Dockerfile.complex

Lines changed: 0 additions & 33 deletions
This file was deleted.

README.md

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,59 @@
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+
```

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/run

Lines changed: 0 additions & 30 deletions
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/type

Lines changed: 0 additions & 1 deletion
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-add-package/up

Lines changed: 0 additions & 1 deletion
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/run

Lines changed: 0 additions & 8 deletions
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/type

Lines changed: 0 additions & 1 deletion
This file was deleted.

root/etc/s6-overlay/s6-rc.d/init-mod-imagename-modname-install/up

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)