Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How not to pass the locale through an ssh connection command

Tags:

bash

ssh

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 ?

like image 261
Sonique Avatar asked Apr 13 '15 15:04

Sonique


People also ask

How do I stop a remote ssh session?

The first way to disconnect from an SSH session is with the exit command. Issue this command on the remote terminal that you are currently logged in to. The second way to disconnect from an SSH session is with the logout command.


2 Answers

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_* 
like image 134
Tom Fenech Avatar answered Sep 25 '22 21:09

Tom Fenech


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* 
like image 40
Xoozee Avatar answered Sep 24 '22 21:09

Xoozee