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 <noreply@anthropic.com>
This commit is contained in:
2026-07-25 15:34:47 +10:00
co-authored by Claude Sonnet 4.6
parent d74efd9f66
commit c3eb2c9e9f
+7 -7
View File
@@ -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