5

For years I have had a problem with the "Setting locales failed". I now understood the problem. On my local machine, my LC_TIME is set to a custom file ("custom.UTF-8"). This custom file does not exist on any remote machine I connect to. However, through SSH my locale setting is 'exported' and searched for at the remote machine. So that is why I keep getting:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_TIME = "custom.UTF-8",
    LANG = "en_US.UTF-8"

What I want to configure is that the local LC_TIME (or any locale variable) is never exported. I am fine just using the value defined at the remote machine. How should I define this?

1 Answer 1

5

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.

2

You must log in to answer this question.