You are not logged in.

#1 2017-08-01 07:25:02

akheron
Member
Registered: 2017-08-01
Posts: 2

ssh and locale

Hi.

I have this in a server's /etc/locale.conf:

LANG=en_US.UTF-8

However, when ssh'ing and not running a shell, the locale is wrong:

$ ssh user@host locale
user@host's password: 
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=

When running through shell, everything works:

$ ssh user@host
user@host's password: 
host $ 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=

Adding

LANG=en_US.UTF-8

to /etc/environment fixes the problem, but doesn't feel like the correct fix.

Offline

#2 2017-08-01 07:43:07

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: ssh and locale

Nothing unusual in that. SSH with a command passed to it is executed as a non-login shell, so /etc/profile.d/* is not sourced, meaning locale.sh is not read.

This sounds like an X-Y problem.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2017-08-01 07:50:49

akheron
Member
Registered: 2017-08-01
Posts: 2

Re: ssh and locale

From locale.conf(5):

The locale settings configured in /etc/locale.conf are system-wide and are inherited by every service or user, unless overridden or unset by individual programs or individual users.

So I thought that every program should inherit the LANG set in /etc/locale.conf.

About my use case: I run weechat inside screen. If I ssh host, then screen -r, special characters work correcly. If I ssh -t host -- screen -r in a single command, then special characters don't work. To make them work, I need to use encoding UTF-8 screen command every time after reattaching.

Allowing the SSH client to send the LANG or LC_* variables doesn't seem the correct solution, because a server generally doesn't have all locales generated. Modifying /etc/environment is the best solution so far, but I still don't understand why every process doesn't inherit what's in /etc/locale.conf. Is the man page just wrong?

Offline

#4 2017-08-01 12:14:00

seth
Member
Registered: 2012-09-03
Posts: 51,213

Re: ssh and locale

jasonwryan wrote:

SSH with a command passed to it is executed as a non-login shell

No user, no service, no locale. The manpage doesn't promise this at all.

You could pass sth. like "bash --login -c screen -r" instead.

Offline

Board footer

Powered by FluxBB