how to disable SendEnv variables set in ssh_config from ~/.ssh/config

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_ADDRESS="$LANG" \
    LC_IDENTIFICATION="$LANG" \
    LC_MEASUREMENT="$LANG" \
    LC_MONETARY="$LANG" \
    LC_NAME="$LANG" \
    LC_NUMERIC="$LANG" \
    LC_PAPER="$LANG" \
    LC_TELEPHONE="$LANG" \
    LC_TIME="$LANG" \
    LC_ALL="$LANG" \
    /usr/bin/ssh $@
}
export -f ssh

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