3

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?

s4y
  • 231
  • 2
  • 7

2 Answers2

2

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
asktyagi
  • 2,860
  • 2
  • 8
  • 25
  • but why it works fine on ssh and not on ssh command? the same login scripts are executed. – gcb Mar 29 '20 at 22:28
  • 1
    AFAIK difference is interactive and non-interactive shell, when you pass command like ssh it will call non-interactive shell, non-interactive shell call `BASH_ENV` instead of other user profiles scripts. – asktyagi Mar 30 '20 at 04:13
  • This works for me. ‘ssh user@yourserver LC_ALL=en_US.UTF-8 command‘ – VincentHuang Aug 13 '21 at 14:33
0

I just noticed, that the problem occurs when I have fish (the fish-shell) set as default (chsh). When I changed my shell back to bash, the locale works as expected.

So:

chsh /bin/bash
z3ntu
  • 1
  • 2
  • only shell on my system is bash, and the problem happens as describe on the question. – gcb Mar 26 '20 at 16:21