When using ssh, if then doing something like sudo -i the environment vars are gone, to preserve modify your sudoers (/usr/local/etc/sudoers or /usr/local/etc/sudoers.d/devops) and add something like:

Defaults env_keep += "SSH_TTY SSH_CONNECTION SSH_CLIENT"

In this case, it will preserve your SSH environment vars.