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.

Posted by on February 24th, 2014

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:


[code]

Defaults env_keep+=SSH_AUTH_SOCK

[/code]

About

Justin is a Sr. Director of Engineering at Deseret Digital Media, Previous President of the Utah PHP Usergroup, and frequently works with the Utah Open Source Foundation which organizes the OpenWest Conference. Justin loves just about anything with web technologies from PHP, JavaScript, Node.js, Salt, and managing engineering teams.

Learn More