大网数据广告活动
服务器运维问答

How to set TERM environment variable in ssh configuration?

· 52CE 我爱测

I use this setting in ~/.ssh/config : Host server Hostname 192.168.x.x SetEnv TERM=xterm But when logging in to the server and doing echo $TERM , I get xterm-256color . How to set TERM from ssh client config file? What is curious…

问题原文

原帖链接 · Igor Liferenko · CC BY-SA 4.0

I use this setting in ~/.ssh/config:

Host server
  Hostname 192.168.x.x
  SetEnv TERM=xterm

But when logging in to the server and doing echo $TERM, I get xterm-256color.

How to set TERM from ssh client config file?

What is curious: when connecting as TERM=xterm ssh server, echo $TERM on server gives xterm. Although this shows that the setting can be transmitted, it does not solve the problem, because I need to set it in config file. Also, putting TERM=xterm in .ssh/environment on server sets it, but it does not solve the problem either, because I cannot edit anything on server.

社区高分解答

原帖链接 · Slim · CC BY-SA 4.0

Since OpenSSH 8.7 (2021-08-20), SetEnv TERM is now supported:

allow ssh_config SetEnv to override $TERM, which is otherwise handled specially by the protocol. Useful in ~/.ssh/config to set TERM to something generic (e.g. "xterm" instead of "xterm-256color") for destinations that lack terminfo entries.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-07-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。