Sample Header Ad - 728x90

How can I preserve an environment variable across su -?

12 votes
4 answers
24846 views
I export LC_ALL="en_US.UTF-8" (via sendEnv in ssh_config) when using ssh to remote systems. When I su - user123 this variable is reset by the login shell. Is there a way to preserve this variable (as well as other LC_xxx variables) when executing a login shell as another user on the remote system? I realize I could export the variable by hand after executing the shell, or an entry in ~/.bashrc of the target user, however I'd rather try to preserve the original values as sent by ssh if possible. Thanks. **EDIT**: I do need specific parts of the user's environment initialized which is why su - is used. I would only want to preserve LC_xxx
Asked by Server Fault (577 rep)
Jan 30, 2017, 06:03 PM
Last activity: Jul 23, 2025, 06:36 AM