You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
root-ubuntu: run one ssh-agent per user under systemd (#35)
Boxes this script provisions had no agent at all, so every ssh and every
tool that leans on one (diskpush, git over ssh, rsync to another host)
either prompted for a passphrase per connection or failed outright.
A systemd user service rather than a line in .zshrc: the shell-snippet
version starts a new agent per shell, so every tmux pane and every
reconnect gets its own, a key added in one is invisible to the next, and
the dead ones accumulate until reboot. The unit lives in /etc/systemd/user
enabled --global, so accounts created later pick it up with no re-run, and
anyone who wants none of it can `systemctl --user mask ssh-agent`.
Two pieces beyond the unit. /etc/profile.d/ssh-agent.sh points login
shells at the socket, because the unit's own Environment= only reaches
services systemd starts, not an sshd login shell; it is POSIX so Debian's
zsh reads it under `emulate sh` too, and it refuses to overwrite a live
inherited SSH_AUTH_SOCK so `ssh -A` forwarding still wins. And linger,
without which the user manager exits with the last session and takes the
agent (and any detached tmux) with it.
No key is ever loaded here -- a passphrase prompt has no place in an
unattended root run.
Verified on this box against real systemd and a real ssh-agent: unit
starts and answers ssh-add, ExecStartPre recovers from a stale socket
file, the snippet resolves the socket under both dash and zsh, keeps an
inherited live agent, and replaces a dead one. Re-running install_ssh_agent
writes nothing the second time.
Claude-Session: https://claude.ai/code/session_01EhwDgBphuy2UKenqMKkezQ
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
0 commit comments