Skip to main content
Topic: Wrong console encoding in ssh session – where can I configure this? (Read 567 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Wrong console encoding in ssh session – where can I configure this?

Hi all!

When I connect to my server via ssh from my Gentoo box, there's no problem. I can use Umlauts etc. as expected.

When I do the same from my Artix box, I can't type Umlauts. E.g. typing "'Ä" yields no output, typing "ÄÖÜ" in a vim session results in "�~D�~V�~\" being displayed and so on.

I think my locale stuff is configured correctly:

/etc/locale.gen:
Code: [Select]
de_DE.UTF-8 UTF-8

/etc/locale.conf:
Code: [Select]
export LANG="de_DE.UTF-8"

Code: [Select]
$ locale
LANG=de_DE.UTF-8
LC_CTYPE="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

What causes this?! Thanks for all help :-)

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #1
Hi,
Which init and desktop are you using?
If you connect via a terminal emulator (i suppose), try starting it with LC_ALL="de_DE.UTF-8", if it works fine then it should be pretty easy to fix.

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #2
I'm using KDE and OpenRC. I'm usually connecting via a konsole session.

Interestingly, the same happens when I start a ssh session from my Gentoo box to the Artix machine, and in this session, I connect to my server. Same result as if the session was started locally. And, when connecting to the Artix machine, ÄÖÜ etc. still work, but as soon as I connect to the (Ubuntu) server, they don't anymore (but they do if I connect from my Gentoo machine directly).

LC_ALL="de_DE.UTF-8" konsole won't help I fear as this locale is already set, konsole is localized etc. – and as said, this also happen when I do an indirect connection with no GUI or DE involved …

Doing LC_ALL=de_DE.UTF8 ssh user@server also doesn't change anything …
EDIT: I now have physical access to the Artix box again. Using konsole directly and starting it via LC_ALL="de_DE.UTF-8" konsole yields (as expected) the same result.

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #3
Quote
Interestingly, the same happens when I start a ssh session from my Gentoo box to the Artix machine, and in this session, I connect to my server.

Okay, that must be some kind of tty business, if you're still at the machine try to switch ttys with ctrl+alt+f2/etc and see in there.
I know very little about this, i was just looking at the service 'termencoding' and maybe also 'consolefont' in OpenRC to see if it might help if you for instance restart it, but might not work locally.
@Dudemanguy if you know more about this help this guy out :)

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #4
Very same result using a "real" console (via CRTL+ALT+F1 etc.) …

This is also reproducible with at least one additional Artix machine I run (fully updated, fresh reboot and so on).

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #5
I thought you were supposed to use vconsole for this. Artix uses this conf file too but I'm not sure.

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #6
What I don't understand is that all that locale stuff is set and also seems to work, but not in that ssh session …

Also if I connect to my Gentoo box from the Artix box, all the Umlaut stuff works. But not if I connect to the Ubuntu server … so, there has to be something Gentoo does, but Artix doesn't or something Artix does that Ubuntu doesn't like …

Additional info: If I call ":set encoding" in vim, I get "utf-8" if I connect from Gentoo, and "latin-1" if I connect from Artix. But only if I connect to the Ubuntu server. If I connect to my Gentoo machine, I also get "utf-8".

So, for whatever reason, I get a latin-1 session when I want an utf-8 one …

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #7
Maybe check the output of
Code: [Select]
locale -k charmap
in various situations?

Is the locale configuration in the Gentoo box exactly the same? (If not, what's different?)
Mine has
Code: [Select]
LC_COLLATE=C
which I vaguely remember being recommended somewhere...
You didn't post your ~/.profile file. Something there could also cause problems.

Finally, I doubt it, but could there be a significant difference in the ssh client setup (version, compilation options, config file)?

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #8
Also if I connect to my Gentoo box from the Artix box, all the Umlaut stuff works. But not if I connect to the Ubuntu server … so, there has to be something Gentoo does, but Artix doesn't or something Artix does that Ubuntu doesn't like …

 :o

https://wiki.ubuntuusers.de/systemd/localectl/
https://wiki.ubuntuusers.de/Spracheinstellungen/#falscher-Zeichensatz-in-der-virtuellen-Konsole
https://wiki.gentoo.org/wiki/Keyboard_layout_switching
"Wer alles kann, macht nichts richtig"

Artix USE="runit openrc slim openbox lxde gtk2 qt4 qt5 qt6 conky
-gtk3 -gtk4 -adwaita{cursors,themes,icons} -gnome3 -kde -plasma -wayland "

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #9
Okay. This seems to be caused by two factors.

1. The Ubuntu server does – despite the locales being set up correctly and also working – not apply the default locale (de_DE.UTF-8) to new ssh connections (I'll have to investigate why this happens …)

2. Artix does not send the locale

Gentoo does the following:

In /etc/ssh/ssh_config (all commented out), the last line is:
Code: [Select]
Include "/etc/ssh/ssh_config.d/*.conf"

And in one of the included files, we have:
Code: [Select]
SendEnv LANG LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME LANGUAGE LC_ADDRESS LC_IDENTIFICATION LC_MEASUREMENT LC_NAME LC_PAPER LC_TELEPHONE

If I add this directive to Artix' /etc/ssh/ssh_config, I get an UTF-8 console with working locale on my Ubuntu server.

Re: Wrong console encoding in ssh session – where can I configure this?

Reply #10
Here we are.

On the server, I configured
Code: [Select]
UsePAM no

in /etc/ssh/sshd_config, because I exclusively wanted public key auth.

Actually, one can set
Code: [Select]
UsePAM yes

along with
Code: [Select]
PasswordAuthentication no
ChallengeResponseAuthentication no

to still only allow public key auth – but with UsePAM set to yes, the locale is applied.