This warning or error is part of the OpenSSH server and macOS or OS X ssh terminal client issues. It can be fixed using various methods.
Understanding LC_* environment variables

Type the following command on the remote server to display all locales supported by Glibc:

$ locale -a

Next, type the following command to display settings on your local system (OSX/Unix/Linux based desktop):

echo "$LC_CTYPE"

The above commands display the country and language names, the character encoding used by the locale.

How to fix "setlocale: LC_CTYPE: cannot change locale (UTF-8)"?

Solution #1: using the Terminal app on OS X

Open your MacOS Terminal app then click on
Terminal > Preferences > Select Terminal type such as Basic (default) > Advanced tab

Make sure that the ‘Set locale environment variables on startup’ is unchecked.

You must close all ssh sessions and relaunch the Terminal app.

Solution #2: Via OpenSSH

Here, we will prevent OpenSSH Client from sending the LC_* variables on OS X / Linux / Unix desktop
Edit /etc/ssh/ssh_config or /etc/ssh_config file, enter:

$ sudo vi ~/.ssh/config
Remove or comment out as follows:
#SendEnv LANG LC_*

Save and close the file.

Solution #3: Installing localedef command

Finally, you can fix this problem by either installing the desired locale using the localedef command or consider choosing a different locale in locale/remote system:

# localedef -i en_US -f UTF-8 en_US.UTF-8

That's it!!

Was this answer helpful? 0 Users Found This Useful (0 Votes)