How do not pass locale through ssh

2020-05-13 12:50发布

I have some aliases for ssh, example:

alias buildWork="ssh work '~/build_app'"

Problem that ssh pass some variables like $LC_CTYPE that cause errors, how to prevent that and use server configs.

标签: bash ssh
4条回答
ゆ 、 Hurt°
2楼-- · 2020-05-13 13:33

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
查看更多
再贱就再见
3楼-- · 2020-05-13 13:36

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_*
查看更多
beautiful°
4楼-- · 2020-05-13 13:44

In short:

$ touch ~/.ssh/config
$ ssh -F ~/.ssh/config your_user@your_host

See this answer for details.

查看更多
爷、活的狠高调
5楼-- · 2020-05-13 13:44
   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
查看更多
登录 后发表回答