summaryrefslogtreecommitdiff
path: root/hetzner-admin/run-command.sh
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-06-19 13:39:27 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-06-19 13:39:27 +0900
commit50e887cb22ca375e66f7948033e05f596c9f43f5 (patch)
tree20ee5aeac8ec69f3f4b23c53ef407f6e62a8d71f /hetzner-admin/run-command.sh
parenta7890e22d52677de267e0d4c79f2c7627f3a96c4 (diff)
Add hetzner-admin: SSH-based server management web UI
Basic Auth protected web UI with buttons to restart services and reboot. SSH key with authorized_keys command= restriction limits executable commands. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'hetzner-admin/run-command.sh')
-rwxr-xr-xhetzner-admin/run-command.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/hetzner-admin/run-command.sh b/hetzner-admin/run-command.sh
new file mode 100755
index 0000000..50280b9
--- /dev/null
+++ b/hetzner-admin/run-command.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+# SSH authorized_keys の command= から呼ばれる。$SSH_ORIGINAL_COMMAND をホワイトリストで検証する。
+set -e
+
+case "$SSH_ORIGINAL_COMMAND" in
+ "docker ps")
+ exec docker ps
+ ;;
+ "docker compose -f /app/infra/caddy/docker-compose.yml restart")
+ exec docker compose -f /app/infra/caddy/docker-compose.yml restart
+ ;;
+ "docker compose -f /app/infra/mail/docker-compose.yml restart")
+ exec docker compose -f /app/infra/mail/docker-compose.yml restart
+ ;;
+ "docker compose -f /app/infra/cgit/docker-compose.yml restart")
+ exec docker compose -f /app/infra/cgit/docker-compose.yml restart
+ ;;
+ "docker compose -f /app/infra/hetzner-admin/docker-compose.yml restart")
+ exec docker compose -f /app/infra/hetzner-admin/docker-compose.yml restart
+ ;;
+ "reboot")
+ exec reboot
+ ;;
+ *)
+ echo "Not allowed: $SSH_ORIGINAL_COMMAND" >&2
+ exit 1
+ ;;
+esac