bash 如何不通过 ssh 传递语言环境

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29609371/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 21:55:24  来源:igfitidea点击:

How do not pass locale through ssh

bashssh

提问by Sonique

I have some aliases for ssh, example:

我有一些 ssh 别名,例如:

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

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

ssh 传递一些类似的变量$LC_CTYPE会导致错误的问题,如何防止这种情况并使用服务器配置。

回答by Tom Fenech

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):

听起来您的 SSH 客户端已配置为转发区域设置。您可以通过更改配置来防止这种情况(全局文件通常为/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_configon the remote machine (note the din sshd_config):

或者,您可以通过/etc/ssh/sshd_config在远程计算机上进行编辑来更改服务器的配置(注意d中的dsshd_config):

# comment out / remove the following line
AcceptEnv LANG LC_*

回答by Rockallite

In short:

简而言之:

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

See this answerfor details.

有关详细信息,请参阅此答案

回答by Luis Mu?oz

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 [email protected]

回答by remigiusz boguszewicz

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.

我遇到了我归因于 ssh 传递语言环境设置的问题,所以我尝试在客户端站点上禁用它,然后在服务器站点上禁用它(如上所述),但登录后语言环境仍然在抱怨。

Turned out to be a messy locale on the destination server itself, where the setting was taken from /etc/default/locale

原来是目标服务器本身的一个混乱的语言环境,设置是从那里获取的 /etc/default/locale

I had to clean it completely, run # dpkg-reconfigure localeswhich fixed the issue.

我不得不彻底清理它,运行# dpkg-reconfigure locales它解决了这个问题。

回答by Azmat

   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 [email protected]
     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 [email protected]
     debug1: Entering interactive session.
     debug1: Sending subsystem: sftp
     Connected to destinationhost