homek8s/infrastructure/networking/rosenpass/linkb-verify.sh
Lance Walters 5fc7cd4ead docs(rosenpass): commit the Link B host artifacts and the endpoint decision
Link B (rpi wg-remote 10.20.0.2 <-> linode wg0 10.20.0.1) is now under
Rosenpass too. The pieces that only existed on the hosts are committed
here with an install/diagnosis write-up, because all three are runtime
state someone will have to rebuild:

- rosenpass-upnp.{sh,service,timer} - re-assert the permanent UPnP mapping
  UDP 9999 -> 192.168.1.125 every 15 min (the router has no admin panel,
  and a dropped mapping is silent).
- linkb-rollback-{rpi,linode}.sh - the self-cancelling watchdogs; this link
  carries the only SSH path to the linode, so the rollback is local and
  staged on both ends before the far unit starts.
- linkb-verify.sh - hashes each end's PSK and compares them without
  printing key material.

Endpoint strategy recorded: the Pi's public address is residential DHCP
but provably static (IGD uptime since 2026-09-10, ~83 days on the
configured 137.118.156.124), so the linode config pins it and a moved
address is caught by the per-interface rotation-age series rather than by
a sync timer.
2026-12-03 02:46:10 -05:00

26 lines
1.4 KiB
Shell
Executable file

#!/bin/bash
# Sample Link B PSK hashes on both ends. Prints no key material: the preshared
# key line is filtered on each host and only its SHA-256 (first 16 hex) leaves.
set -u
LINKB_LINODE='/2Y0XpJYd9Vl9Al6zNAlQimEYA+xY9Y5PO6nUDkfKEA=' # linode wg0 pub (peer on the Pi)
LINKB_RPI='h1v1Rhrnq2N2kt454xQamL1Y1x0TaICa1zoKgyZHpkM=' # rpi wg-remote pub (peer on the linode)
LINKA='+e50qTPdZiyxMtYHRSdGILIrh06JflFQq5+TZRjVyic=' # siriussec (Link A sentinel)
h() { tr -d '\n' | sha256sum | cut -c1-16; }
ts=$(date -u +%FT%TZ)
pi_linkb=$(wg show wg-remote preshared-keys 2>/dev/null | grep -F "$LINKB_LINODE" | awk '{print $2}' | h)
pi_linka=$(wg show wg0 preshared-keys 2>/dev/null | grep -F "$LINKA" | awk '{print $2}' | h)
ln_linkb=$(ssh -n -i /home/sirius/.ssh/linode_admin -o BatchMode=yes -o ConnectTimeout=10 [email protected] \
"wg show wg0 preshared-keys | grep -F '$LINKB_RPI' | awk '{print \$2}'" | h)
pi_hs=$(wg show wg-remote latest-handshakes 2>/dev/null | grep -F "$LINKB_LINODE" | awk '{print $2}')
ln_hs=$(ssh -n -i /home/sirius/.ssh/linode_admin -o BatchMode=yes -o ConnectTimeout=10 [email protected] \
"wg show wg0 latest-handshakes | grep -F '$LINKB_RPI' | awk '{print \$2}'")
agree="MISMATCH"
[ "$pi_linkb" = "$ln_linkb" ] && agree="agree"
printf '%s linkB pi=%s linode=%s %s | linkA(pi)=%s | hs pi=%s linode=%s\n' \
"$ts" "$pi_linkb" "$ln_linkb" "$agree" "$pi_linka" "$pi_hs" "$ln_hs"