SSH – Fix Wrong Locale Settings

localizationpamputtyssh

I have a debian server with locales set to hu_HU.UTF-8, and if i log in trough console it works perfectly in hungarian. It also worked with ssh logins until i disabled PAM in the sshd config. Since then when i log in trough ssh the locales are set to POSIX.

I tried to comment the AcceptEnv LANG LC_* line in sshd_config but the problem still exits.
I'm connecting with Putty with UTF-8 character set.

So how can i fix this?

Best Answer

PuTTY doesn't set LANG

The locale you have set in PuTTY is completely decoupled from the environment variables on the system. To quote its documentation:

Unfortunately, there is no satisfactory mechanism for PuTTY and the server to communicate this information, so it must usually be manually configured.

Before PuTTY changed the default character encoding to UTF-8, it was an extremely common scenario for the OS to have settings defaulting to a UTF-8 enabled locale (typically en_US.UTF-8) with PuTTY misinterpreting that by its own ISO-8859-1:1998 default.

PAM is more than just authentication

More than likely you've turned UsePAM to no, not realizing that this turns off far more than just PAM authentication. The operative words from the sshd_config manpage are:

Enables the Pluggable Authentication Module interface. If set to “yes” this will enable PAM authentication using ChallengeResponseAuthentication and PasswordAuthentication in addition to PAM account and session module processing for all authentication types.

Your console logins are still invoking PAM modules associated with the account and session facilities, but your SSH logins are no longer doing so. I recommend that you re-enable PAM. At this point you can disable PasswordAuthentication and ChallengeResponseAuthentication if your goal is to require key based authentication. (which has always bypassed PAM's auth facility)