I couldn't find that anywhere so I'm wondering am I the only one hitting such issue.

By default ssh on Red Hat and Debian at least has a ssh_config with SendEnv option passing LC* and LANG variables in the remote session. If one is not root to change /etc/ssh/ssh_config, how can he disable that behavior? SendEnv option seems to be accumulating and I can't see any way to reset it.

And to avoid being asked, I need to avoid passing my locale to test machines to avoid side effects on scripts and programs that rely on locale being the default for the machine.

  • This is not an answer to your question, but can you solve your problem by invoking the scripts and programs on your test machines through env or with a wrapper script? Oct 9, 2012 at 20:57
  • 2
    yeah, workarounds are possible but inconvenient Oct 10, 2012 at 7:34

6 Answers 6


You're not the only one. As documented in ssh_config(5) you can't unset SendEnv, because

Multiple environment variables may be [...] spread across multiple SendEnv directives.

If you have root on the test machines you could change AcceptEnv to not accept variables sent by the client, though.


This can't be done in ~/.ssh/config because SendEnv cannot be overridden.

Using aliases won't work for scripts that call ssh.

One alternative is to export a function. E.g. in ~/.bashrc:

function ssh() {
    LANG="en_US.UTF-8" \
    LC_NAME="$LANG" \
    LC_PAPER="$LANG" \
    LC_TIME="$LANG" \
    LC_ALL="$LANG" \
    /usr/bin/ssh $@
export -f ssh
  • This is bloody stupid. Mar 20, 2020 at 18:35

According to man ssh:

 -F configfile
         Specifies an alternative per-user configuration file.  If a con-
         figuration file is given on the command line, the system-wide
         configuration file (/etc/ssh/ssh_config) will be ignored.  The
         default for the per-user configuration file is ~/.ssh/config.

So, you can ssh without complying with /etc/ssh/ssh_config by explicitly specifying the (default) configuration file on the command line (~/.ssh/config is OK to be empty):

$ touch ~/.ssh/config
$ ssh -F ~/.ssh/config your_user@your_host

You can make an alias for it in ~/.bashrc:

alias ssh="ssh -F ~/.ssh/config"

Restart the bash shell, then you can simply ssh like this:

$ ssh your_user@your_host

There's option SetEnv, one can force LANG to some specific value before sending it.

Also man page says that

It is possible to clear previously set SendEnv variable names by prefixing patterns with -.

but I didn't manage to make this work.

  • See bugzilla.mindrot.org/show_bug.cgi?id=1285 , probably that will explain why the - approach did not work. Good suggestion though to hardcode remote LANG and other vars in ssh config. Makes things more predictable. Perhaps SetEnv is a newer directive because nobody else suggested about it. SetEnv LANG=en_US.UTF-8 May 13, 2019 at 14:31

If you are using bash you may set up an alias ssh='LANG= command ssh' to disable LANG passing to the other servers.


You can use su - youruser when you are logged in over ssh. This will reinitialize the environment for the user.

Actually you initialize a new session with a new environment.

  • Question is to have environment sane automatically. And btw su is not always installed. And you have to type in your password with su. Not useful. There are easier workarounds. Apr 15, 2015 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .