I have some aliases for ssh, example:
alias buildWork="ssh work '~/build_app'"
The problem is that the ssh
command passes some variables like $LC_CTYPE
that causes some errors.
How to prevent that and use the server configurations ?
I have some aliases for ssh, example:
alias buildWork="ssh work '~/build_app'"
The problem is that the ssh
command passes some variables like $LC_CTYPE
that causes some errors.
How to prevent that and use the server configurations ?
It sounds like your SSH client is configured to forward the locale settings. You can prevent this by altering your configuration (the global file is typically /etc/ssh/ssh_config
):
# comment out / remove the following line
SendEnv LANG LC_*
Alternatively you can change the configuration of the server, by editing /etc/ssh/sshd_config
on the remote machine (note the d in sshd_config
):
# comment out / remove the following line
AcceptEnv LANG LC_*
As already explained in other answers, the client will send all environment variables specified via SendEnv
in /etc/ssh/ssh_config
. You can also force ssh
to not send already defined variable names, using your user's configuration.
From OpenSSH man page:
It is possible to clear previously set SendEnv variable names by prefixing patterns with -. The default is not to send any environment variables.
So, to prevent sending your locale, you can put the following into your ~/.ssh/config
:
SendEnv -LC_* -LANG*
In short:
$ touch ~/.ssh/config
$ ssh -F ~/.ssh/config your_user@your_host
See this answer for details.
Accepted answer is correct, but, if you don't want to change your config files, you can override specific locale on the command line
LC_TIME="en_US.UTF-8" ssh user@example.com
I was facing the issue that I attributed to ssh passing the locale settings, so I tried with disabling it on client site, then on server site as well (as advised above) and still the locale was complaining after logging in.
Turned out to be a messy locale on the destination server itself, where the setting was taken from /etc/default/locale
I had to clean it completely, run # dpkg-reconfigure locales
which fixed the issue.
To not send our Local Environment (SendEnv) which is the default behaviour since it is specified in /etc/ssh/ssh_config
you have to:
~/.ssh/config
Host *
SendEnv !LANG !LC_*
sudo su - $YourSelf
(or logout/login)source: https://bugzilla.mindrot.org/show_bug.cgi?id=1285#c8
Remember that not everyone with this issue will have the power of editing /etc/ssh/ssh_config
To stop sending Environment Variables via sftp Tested on CENTOS 7 - create file config in ~/xyzuser/.ssh/config - set permission to 600 ~/xyzuser/.ssh/config - Put the following content in the file comment the below lines commented to disable env variables######### - Send locale-related environment variables SendEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY SendEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE SendEnv LC_IDENTIFICATION LC_ALL LANGUAGE SendEnv XMODIFIERS Running without the ~/xyzuser/.ssh/config sftp -v xyzuser@destinationhost -------------------truncated output-------- debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 debug1: Sending subsystem: sftp Running with the ~/xyzuser/.ssh/config sftp -v -F /home/xyzuser/.ssh/config xyzuser@destinationhost ----truncated---------- debug1: channel 0: new [client-session] debug1: Requesting no-more-sessions@openssh.com debug1: Entering interactive session. debug1: Sending subsystem: sftp Connected to destinationhost