It is rather dangerous to have `sudo` inherit the environment (variables like `LD_PRELOAD` probably shouldn't be inherited). 

An alternative solution that I don't like would be to walk up the chain of parent processes until `ssh` is found.