From 0c29c6a93d11aa5cc8ef360469481e7956d8a48c Mon Sep 17 00:00:00 2001 From: beatzaplenty Date: Sat, 25 Jul 2026 15:34:47 +1000 Subject: [PATCH] fix(push-host-keys): fix sudo PTY allocation failure ssh -t won't allocate a PTY when its own stdin is redirected (by a heredoc). Replaced the heredoc-fed 'sudo bash -s' with commands passed as an argument string so stdin stays free and -t can properly allocate a PTY for the sudo password prompt. Co-Authored-By: Claude Sonnet 4.6 --- scripts/secrets/push-host-keys.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/secrets/push-host-keys.sh b/scripts/secrets/push-host-keys.sh index a74d73f..09b3a87 100755 --- a/scripts/secrets/push-host-keys.sh +++ b/scripts/secrets/push-host-keys.sh @@ -145,15 +145,15 @@ _do_push() { scp -o StrictHostKeyChecking=no \ "$pubfile" "${SSH_USER}@${hostname}:/tmp/push_ed25519_key.pub" - # Install with correct permissions in one interactive sudo session + # Install with correct permissions via sudo. Commands are passed as an + # argument string (not heredoc) so stdin stays free and -t can allocate + # a PTY for the sudo password prompt. echo " (sudo password may be required)" ssh -t -o StrictHostKeyChecking=no "${SSH_USER}@${hostname}" \ - "sudo bash -s" <<'REMOTE' -install -m 0600 /tmp/push_ed25519_key /etc/ssh/ssh_host_ed25519_key -install -m 0644 /tmp/push_ed25519_key.pub /etc/ssh/ssh_host_ed25519_key.pub -rm -f /tmp/push_ed25519_key /tmp/push_ed25519_key.pub -echo " [ok] host key installed" -REMOTE + "sudo install -m 0600 /tmp/push_ed25519_key /etc/ssh/ssh_host_ed25519_key && + sudo install -m 0644 /tmp/push_ed25519_key.pub /etc/ssh/ssh_host_ed25519_key.pub && + sudo rm -f /tmp/push_ed25519_key /tmp/push_ed25519_key.pub && + echo ' [ok] host key installed'" # Drop the stale known_hosts entry for this host (public key just changed) ssh-keygen -R "$hostname" 2>/dev/null || true