fix(deploy): set up 'deploy-rs' wrapper for hardware-backed SSH keys

This commit is contained in:
2026-07-02 20:22:01 +02:00
parent cf3095556d
commit 8c2230f158
2 changed files with 47 additions and 1 deletions
@@ -0,0 +1,34 @@
# `deploy` wrapper script that opens a short-lived SSH master process for
# `deploy-rs` to use so it works with hardware-backed key touch+PIN. assumes
# ControlPath ~/.ssh/socket-%r@%h:%p (see ./default.nix)
# extract the target host from the `deploy-rs` flake target (e.g. `.#hecuba`)
node=""
for arg in "$@"; do
case "$arg" in
-*) ;;
*'#'*)
node="${arg#*#}" # strip flake ref up to '#'
node="${node%%@*}" # strip '@user'
node="${node%%.*}" # strip '.profile'
;;
esac
done
master=0
if [[ -n "$node" ]] && ! ssh -O check "$node" 2>/dev/null; then
# place ssh client into "master" mode for connection sharing (see `man ssh`)
if ssh -fNM "$node"; then
master=1
fi
fi
rc=0
@deploy@ "$@" || rc=$?
# request the master process to exit (see `man ssh`)
if ((master)); then
ssh -O exit "$node" 2>/dev/null || true
fi
exit "$rc"