Linux – POSIX locale when I use SSH with a command line

linuxlocalizationssh

When I SSH into an Arch Linux server and include a command line, I end up with a POSIX locale:

laptop.lan$ ssh server.lan locale
LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
laptop.lan$

As far as I can tell, locale is set up correctly on the server. /etc/locale.conf looks like this:

LANG=en_US.UTF-8

And, when I SSH in normally, my locale is fine:

laptop.lan$ ssh server.lan
server.lan$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
server.lan$

What’s going on here, and how can I make one-shot commands use my preferred locale, too?

Best Answer

I guess some defaults are applied here, I am not sure about version but my first thoughts are below

Forward locale

SendEnv LANG LC_*

Or

you can change the configuration of the server, by editing /etc/ssh/sshd_config on the remote machine:

Accept locale

AcceptEnv LANG LC_*

Or

You can use ssh config file pass your locale to ~/.ssh/config and use

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

Or

use below way for inline changes

LC_TIME="en_US.UTF-8" ssh usernae@yourserver