Disable Locale Environment Passing in SSH

Some UNIX-based systems, like Linux and macOS, can have an SSH feature enabled which may lead to odd outputs after connecting to a remote host over SSH.

An example output after executing locale on the remote host could be:

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory 

Executing other random programs like git can bring up outputs like:

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:

In this case, SSH on your local system is configured to pass its locale environment values to the remote system. If the remote host, though, does not know or support them, error messages like the ones above can appear.

To fix this, you can either set up the remote host in a way so that it supports the passed locale environments, or you can configure SSH on your remote host to ignore passed locale environments.

Since often you may not have the rights to change these things on a remote system, I found the more general way for fixing this problem is to disable the locale environment passing on your local system.

You can do this by editing with admin rights /etc/ssh/ssh_config and commenting out:

# SendEnv LANG LC_*

Recent versions of macOs have this setting enabled by default.