diff --git a/development.ini b/development.ini --- a/development.ini +++ b/development.ini @@ -238,6 +238,12 @@ ssh_enabled = false ## Path to be used in ssh_authorized_keys file to invoke kallithea-cli with ssh-serve. #kallithea_cli_path = /srv/kallithea/venv/bin/kallithea-cli +## Locale to be used in the ssh-serve command. +## This is needed because an SSH client may try to use its own locale +## settings, which may not be available on the server. +## See `locale -a` for valid values on this system. +#ssh_locale = C.UTF-8 + #################################### ### CELERY CONFIG #### #################################### diff --git a/kallithea/bin/kallithea_cli_ssh.py b/kallithea/bin/kallithea_cli_ssh.py --- a/kallithea/bin/kallithea_cli_ssh.py +++ b/kallithea/bin/kallithea_cli_ssh.py @@ -45,6 +45,11 @@ def ssh_serve(user_id, key_id): sys.stderr.write("SSH access is disabled.\n") return sys.exit(1) + ssh_locale = kallithea.CONFIG.get('ssh_locale') + if ssh_locale: + os.environ['LC_ALL'] = ssh_locale # trumps everything, including LANG, except LANGUAGE + os.environ['LANGUAGE'] = ssh_locale # trumps LC_ALL for GNU gettext message handling + ssh_original_command = os.environ.get('SSH_ORIGINAL_COMMAND', '') connection = re.search('^([\d\.]+)', os.environ.get('SSH_CONNECTION', '')) client_ip = connection.group(1) if connection else '0.0.0.0' diff --git a/kallithea/lib/paster_commands/template.ini.mako b/kallithea/lib/paster_commands/template.ini.mako --- a/kallithea/lib/paster_commands/template.ini.mako +++ b/kallithea/lib/paster_commands/template.ini.mako @@ -341,6 +341,12 @@ ssh_authorized_keys = ${user_home_path}/ kallithea_cli_path = ${kallithea_cli_path} %endif +<%text>## Locale to be used in the ssh-serve command. +<%text>## This is needed because an SSH client may try to use its own locale +<%text>## settings, which may not be available on the server. +<%text>## See `locale -a` for valid values on this system. +#ssh_locale = C.UTF-8 + <%text>#################################### <%text>### CELERY CONFIG #### <%text>####################################