Ssh – How to set TERM environment variable in ssh configuration

ssh

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.

Best Answer

Adjusting the configuration to this can be used as a workaround:

Host server
  Hostname 192.168.x.x
  RemoteCommand TERM=xterm $SHELL
  RequestTTY yes

Probably worthwhile mentioning it comes with a caveat; the section will no longer work when explicitly giving a command as an argument to ssh, or with sftp, sshfs etc.