SSH_AUTH_SOCK
environment variable when using sudo su
enables forwarding of user's SSH agent connection to root environment
(umask 0440; echo 'Defaults env_keep += "SSH_AUTH_SOCK"' > /etc/sudoers.d/ssh-auth-sock)Example of using
/etc/sudoers.d/ssh-auth-sock
on host
machine. The example assumes that the user copied already their public SSH key to the destination machines under root user:
$ ssh -A user@host [user@host]$ sudo su [root@host]# ssh remote [root@remote]#