All writing

SSH Key Forwarding & Sudo

Lately I’ve been really liking using SSH Key Forwarding to let a server I’m SSH’d into authorize against my key. Most of the time it is so I can pull private git repositories on a server. The problem is when I use sudo I lose my current environment variables. Thanks to ServerFault, I found a great work-around where sudo can forward the SSH_AUTH_SOCK environment variable. You can do this by using visudo to add the following line:

Defaults    env_keep+=SSH_AUTH_SOCK
Sheet
A-3 · Detail
Drawn
Utah
Scale
1:1
Rev
2026