Document the real deploy setup: SSH port, deploy user, shared key
Test and deploy / test (pull_request) Successful in 2m29s
Test and deploy / deploy (pull_request) Skipped

- SSH on port 42069, deploy user plesk-nachklang, one deploy key for all
  Nachklang repos as a Gitea organisation secret (host, port and user as
  organisation variables; path and build values per repository).
- Key-only login for the deploy user via a Match block in sshd_config.
- Plain /bin/bash instead of Plesk's chrooted shell: bash segfaults in the
  chroot copy on this server, so every session closed right after login;
  the read-access trade-off and a stricter rrsync option are noted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
PaddyandClaude Opus 5.5 committed 2026-11-08 21:46:54 +01:00
1 parent b0cd657fd9
commit 38eff139be
2 files changed
+75 -29

No files matched your search

+70 -29
View File
@@ -8,7 +8,7 @@ real deploy settles them - record the outcome here.
```
push to master ──▶ Gitea ──▶ runner (Docker container on the Plesk server)
├─ test job: npm ci, lint, tsc, test, build
└─ deploy job: build ─ rsync over SSH ─▶ nachklang@server:<app root>
└─ deploy job: build ─ rsync over SSH ─▶ plesk-nachklang@server:<app root>
└─ touch tmp/restart.txt
browser ──https──▶ Plesk (nginx + Passenger) ──▶ <app root>/server.js
```
@@ -18,7 +18,7 @@ Pull requests only run the test job.
## Why SSH and not mounted paths
Decided 2026-11-08. The Jenkins job wrote into the webroot through a path shared with the host.
The workflow instead connects as the subscription's own system user (`nachklang`) with a
The workflow instead connects as the subscription's own system user (`plesk-nachklang`) with a
dedicated deploy key: the job can only touch what that user can, files get the right owner
without `chown`, nothing on the host is mounted into the runner, and the same steps work for any
Node app on Plesk and keep working if the runner moves. No release folders: rsync writes straight
@@ -26,55 +26,96 @@ into the app root, and a rollback is a redeploy of an older commit.
## One-time setup
### 1. SSH access for `nachklang` (Plesk)
### 1. SSH access for `plesk-nachklang` (Plesk)
*Websites & Domains → nachklang.art → Hosting & DNS → Hosting* (wording may differ by Plesk
version): set **Access to the server over SSH** from "Forbidden" to `/bin/bash (chrooted)`.
*Unverified* whether the chrooted environment includes `rsync`; if the first deploy fails with
"rsync: command not found" on the remote side, switch to `/bin/bash`.
version): set **Access to the server over SSH** from "Forbidden" to **`/bin/bash`** (not chrooted).
`rsync` must be installed on the server (`command -v rsync`, else `apt-get install rsync`).
Why not chrooted (found 2026-11-08): with "/bin/bash (chrooted)" Plesk sets the shell to
`/opt/psa/bin/chrootsh`, which runs bash inside a copy of a system in the home folder
(`/var/www/vhosts/nachklang.art/{bin,lib,usr,…}`). That copy is broken on this server - `bash`
segfaults in it (`chroot … /bin/bash` → exit 139; it mixes libraries from several Debian releases,
likely a `libc` mismatch) - so every SSH session closed right after login. It also has no `rsync`.
Repairing it would mean rebuilding Plesk's chroot template and keeping it current after upgrades.
Trade-off accepted by the user: without the chroot the user can **read** world-readable files
elsewhere on the system (`/etc`, `/usr`, the process list), but **write** only where it could
before (its home with all Nachklang sites, `/tmp`); other subscriptions' homes stay unreadable
(`drwx--x---`, group `psaserv`). All Nachklang apps run as this one user anyway. A stricter
option, if ever wanted: force `command="rrsync /var/www/vhosts/nachklang.art",restrict` on the
deploy key in `authorized_keys` (rsync only, inside that folder, no shell) - the workflow would
then upload `tmp/restart.txt` instead of running `touch`, and `DEPLOY_PATH` would become relative.
**Key-only login.** Password and keyboard-interactive login are off for `plesk-nachklang`
(set up 2026-11-08): globally the server had `PasswordAuthentication yes` and
`KbdInteractiveAuthentication no`; a `Match User plesk-nachklang` block at the end of
`/etc/ssh/sshd_config` sets both to `no` for this user (confirmed by the user with `sshd -T -C`). Don't lock the account password
instead (`passwd -l`) - on Plesk the subscription user's password is also its FTP password
(inferred, not checked). Check with:
```bash
sudo sshd -T -C user=plesk-nachklang,host=test,addr=127.0.0.1 | grep -Ei '^(passwordauthentication|kbdinteractiveauthentication) '
ssh -p 42069 -o PubkeyAuthentication=no -o PreferredAuthentications=password plesk-nachklang@nachklang.art # must be refused at once
```
### 2. Deploy key
On any machine:
```bash
ssh-keygen -t ed25519 -N "" -f calendar-deploy -C "gitea-actions Calendar_Frontend"
ssh-keygen -t ed25519 -N "" -f nachklang-deploy -C "gitea-actions Nachklang"
```
- Append `calendar-deploy.pub` to `~/.ssh/authorized_keys` of `nachklang` on the server (Plesk's
SSH key management or the file manager; create `.ssh` with mode 700, the file with 600).
- The private key `calendar-deploy` goes into Gitea as a secret (below), then delete the local copy.
**One key for all Nachklang repos** (decided 2026-11-08: less upkeep; all apps run as the same
system user `plesk-nachklang` anyway - inferred from the shared `/var/www/vhosts/nachklang.art`, so
per-repo keys would only have added finer revocation, not isolation). The user generates and holds
the key; it never passes through Claude.
- Append `nachklang-deploy.pub` to `~/.ssh/authorized_keys` of `plesk-nachklang` on the server (as root:
`install -d -m 700` the `.ssh` folder owned by `plesk-nachklang`, file mode 600).
- The private key goes into Gitea as an **organisation** secret (below).
- Possible hardening later: restrict the key in `authorized_keys` (`restrict`, or `rrsync` limited
to one folder - would need the restart done by uploading `tmp/restart.txt` instead of `touch`).
### 3. Host key
The job refuses any server whose host key it doesn't already know. Get the line it needs from
a machine that can reach the server, and compare its fingerprint with the server's own:
SSH listens on **port 42069** (22 is closed). The job refuses any server whose host key it doesn't
already know. Get the line from a machine that can reach the server, and compare its fingerprint
with the server's own:
```bash
ssh-keyscan -t ed25519 <DEPLOY_HOST> # → the secret DEPLOY_KNOWN_HOSTS
ssh-keyscan -p 42069 -t ed25519 nachklang.art # → the secret DEPLOY_KNOWN_HOSTS
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub # on the server: must match
```
Scanned 2026-11-08: `SHA256:iL7O98pO1vC4wDBVY88yo0xV5nwdxeE5vtAjqfOUpWI` for `[nachklang.art]:42069`.
`DEPLOY_HOST` must be reachable **from inside the runner's job containers**, which run on the
same server. The server's public hostname is the obvious choice; *unverified* that the server
can reach itself on its public address. If it can't, use the Docker bridge gateway instead (on
default Docker installs `172.17.0.1`) and scan that address for the known-hosts line.
same server in a per-job Docker network (no `network` set in the runner's `config.yaml`). The
public hostname is used; *unverified* that a job container can reach the host on its public
address. If it can't, use the job network's gateway (or add
`--add-host=host.docker.internal:host-gateway` to the runner's `container.options`) and scan that
address for the known-hosts line.
### 4. Gitea repository settings
### 4. Gitea settings
*Calendar_Frontend → Settings → Actions* (Actions must be enabled for the repo):
What every Nachklang repo shares goes on the **organisation** (*Nachklang → Settings → Actions*);
what is specific to this app on the **repository** (*Calendar_Frontend → Settings → Actions*;
Actions must be enabled for the repo). A repository value overrides an organisation value of the
same name. The workflow reads both the same way (`secrets.*`, `vars.*`).
| Kind | Name | Value |
|---|---|---|
| Secret | `DEPLOY_SSH_KEY` | private key from step 2 |
| Secret | `DEPLOY_KNOWN_HOSTS` | line(s) from step 3 |
| Variable | `NEXT_PUBLIC_API_BASE_URL` | `https://api.nachklang.art` |
| Variable | `NEXT_PUBLIC_ADMIN_APP_URL` | `https://admin.nachklang.art` |
| Variable | `DEPLOY_HOST` | from step 3 |
| Variable | `DEPLOY_USER` | `nachklang` |
| Variable | `DEPLOY_PATH` | `/var/www/vhosts/nachklang.art/calendar.nachklang.art` |
| Variable | `DEPLOY_PORT` | only if SSH isn't on 22 |
| Variable | `DEPLOY_SMOKE_URL` | `https://calendar.nachklang.art/` - **only after step 5** |
| Level | Kind | Name | Value |
|---|---|---|---|
| Org | Secret | `DEPLOY_SSH_KEY` | private key from step 2 |
| Org | Secret | `DEPLOY_KNOWN_HOSTS` | line from step 3 |
| Org | Variable | `DEPLOY_HOST` | `nachklang.art` |
| Org | Variable | `DEPLOY_PORT` | `42069` |
| Org | Variable | `DEPLOY_USER` | `plesk-nachklang` |
| Repo | Variable | `DEPLOY_PATH` | `/var/www/vhosts/nachklang.art/calendar.nachklang.art` |
| Repo | Variable | `NEXT_PUBLIC_API_BASE_URL` | `https://api.nachklang.art` |
| Repo | Variable | `NEXT_PUBLIC_ADMIN_APP_URL` | `https://admin.nachklang.art` |
| Repo | Variable | `DEPLOY_SMOKE_URL` | `https://calendar.nachklang.art/` - **only after step 5** |
The `NEXT_PUBLIC_*` values are inlined at build time; they are variables, not secrets, because
they end up in the JavaScript every visitor downloads anyway.