chore: init

This commit is contained in:
Job79 committed 2026-11-15 15:52:10 +01:00
commit 9245b26500
42 files changed
+601

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
# Every boot (agent-boot.service), and after the setup: sets the hostname asked at setup (/etc is
# read-only, so it is set on every boot), makes the ssh host key the first time, and wipes
# Claude's config except its login, so Claude starts fresh but logged in.
set -euo pipefail
cd /var/lib/agent
hostnamectl hostname --transient "$(cat hostname)"
[[ -f ssh_host_ed25519_key ]] || ssh-keygen -q -t ed25519 -N '' -f ssh_host_ed25519_key
find claude -mindepth 1 -maxdepth 1 ! -name .credentials.json ! -name .claude.json -exec rm -rf {} +
+29
View File
@@ -0,0 +1,29 @@
#!/bin/bash
# First boot: asks for the root password, the hostname and the ssh key of the user claude, on the
# screen (tty1) and the serial console (ttyS0) at once (agent-setup@.service).
# /etc is read-only, so the answers go to /var/lib/agent: the password to a shadow file there
# (etc-shadow.mount puts it over /etc/shadow), the rest is applied by agent-boot at every boot.
set -euo pipefail
echo "== Agent setup =="
while :; do
read -rsp "Root password: " pw; echo
read -rsp "Again: " pw2; echo
[[ -n $pw && $pw == "$pw2" ]] && break
echo "Passwords do not match, try again."
done
install -d -m 0700 /var/lib/agent/etc
cp /etc/passwd /etc/shadow /var/lib/agent/etc/
echo "root:$pw" | chpasswd --prefix /var/lib/agent
systemctl start etc-shadow.mount
read -rp "Hostname [agent]: " name
read -rp "SSH public key for the user claude: " key
[[ -n $key ]] && install -m 0644 /dev/stdin /var/lib/agent/authorized_keys <<<"$key"
# Written last: its presence marks the setup as done.
echo "${name:-agent}" > /var/lib/agent/hostname
systemctl start agent-boot.service sshd.service
echo "Done. Log in with ssh claude@<this VM>, run claude and log in with your account."
echo "Remote Control then starts by itself."
# Stop the setup on the other console, which then shows its login.
systemctl --no-block stop "agent-setup@*.service"