Selectively preserve environment variables

Instead of using option -E, configure specific environment variables that should be preserved.

$ sudo visudo
Defaults env_keep += "MY_ENVIRONMENT_VARIABLE"

localhost in sudoers

Don’t use the string localhost in sudoers, use either string ALL or the actual name of the host (/etc/hostname).

%admin ALL=(ALL) NOPASSWD: ALL
%admin <name of host>=(ALL) NOPASSWD: ALL

References