keep ssh-agent for sudo

I am working a lot via ssh on different Linux servers. For authentication on those I always use a ssh key. I am also tunneling my ssh key for git to those servers because I often need to work with git repositories there (containing configuration files for example).

Of course I need those ssh keys also when I am working with sudo and last week I had to make this work on a new server again. The trick is to configure the following line in the /etc/sudoers file:

Defaults env_keep+=SSH_AUTH_SOCK

This keeps the environment of SSH_AUTH_SOCK around while in the sudo context and sudo git will work with my credentials.