1

What's the proper way to configure sudo to keep the SSH_AUTH_SOCK environment variable?

I was following some guide on the Internet, but it is not working for me:

$ printenv | grep SSH
SSH_AUTH_SOCK=/tmp/ssh-Zy2v8uDtJxPw/agent.2628
SSH_AGENT_PID=2629

$ sudo printenv | grep SSH | wc 
      0       0       0

I thought I need to restart sudo service, but How To Restart Sudo Service on Ubuntu 16.10 says no need.

xpt
  • 1,045
  • Check out the env_keep option in /etc/sudoers (man sudoers). – Gunnar Hjalmarsson Aug 08 '19 at 07:50
  • I know the env_keep option and I've added SSH_AUTH_SOCK, but it is not working, without restarting Sudo Service, as seen in OP. Your comment doesn't provide much help I'm afraid, @GunnarHjalmarsson. Have you actually tried it before your reply? – xpt Aug 08 '19 at 12:02
  • It was sad that pointing at the documented way to do it wasn't helpful. Good luck! – Gunnar Hjalmarsson Aug 08 '19 at 12:19
  • That's a very weird way to show being helpful. Guess how many git questions are asked on stackoverflow, despite there are "documented way to do it", then check out if your guess was close enough at https://stackoverflow.com/questions/tagged/git – xpt Aug 08 '19 at 12:46

1 Answers1

2
sudo -E printenv | grep SSH

-E Preserves your environment variables into the sudo.

Eliah Kagan
  • 117,780