The easiest way to "prevent" the exporting of the environment is to overwrite them in your user account on the server side. To do so you can create a .bashrc
file (or the appropriate initialization file for your shell) and overwrite the unwanted variables.
example minimal .bashrc
file:
unset LC_TIME
alternatively set the variable to some sane value:
export LC_TIME=en_US.UTF-8
If you really want to prevent sending some of environment variables then you will most likely need root access on the client and/or the server machine.
On the client side you can edit /etc/ssh/ssh_config
and remove or alter the SendEnv
line. Most distributions today have that set up to send the locale environment variables (LC_*
).
There is a user config file (~/.ssh/config
) where you can also set SendEnv
. But there you can only append to the list from the system config file, not overwrite. That is why you can only truly disable this option when you have root access.
Alternatively, on the server side you can edit /etc/ssh/sshd_config
(note the extra d
at sshd_config
. the d
stands for daemon) and remove or alter the AcceptEnv
line. Most distributions today have that set up to accept the locale environment variables (LC_*
).
Look up the explanations for SendEnv
in the man page for ssh_config and AcceptEnv
in the man page for sshd_config.
For the sake of completeness: there is also a PermitUserEnvironment
in sshd_config
. As the name says, it allows the user to set up some files which will initialize some variables. If PermitUserEnvironment
is enabled you can take care of the rest as user, but I have never encountered a system with PermitUserEnvironment
enabled.