0

I have a host that doesn't have the termcap entries for non-standard terminals and I cannot add them (policy).

I use tmux which sets a terminal type to something that this device does not recognise. No issue here, worst case I can set the TERM to 'xterm' and be done with it. But:

I've configured some defaults for the OpenSSH client, among other settings, I instructed it to not send any environment variables other than LANG and LC_*.

The relevant part of ~/.ssh/config:

Host *
  SendEnv LANG LC_*

My OpenSSH client version is 6.6.1.

Here's the transcript of my SSH session with irrelevant lines removed:

% TERM=you.shall.not.pass ssh -vvv host
...
debug1: Connection established.
...
debug1: Authentication succeeded (publickey).
...
debug1: Sending environment.
...
debug1: Sending env LANG = en_GB.UTF-8
debug2: channel 0: request env confirm 0
...
debug3: Ignored env TERM

As per the above, it sent LANG, wrote it ignored TERM but yet somehow it has propagated to the remote host:

root@host% echo $TERM
you.shall.not.pass

Is this something you've come across? It's not a major issue but I thought that unless I'm doing something wrong, this is inconsistent with the documentation.

Marcin Kaminski
  • 243
  • 2
  • 10

1 Answers1

1

Ssh doesn't pass the value of TERM as an environment variable per se. The SSH protocol message for requesting a pseudo-terminal (PTY) has a field for the terminal type, along with things like the terminal's width and height. See RFC 4254, Section 6.2.

Try running a command without a PTY, and you'll probably get different results, for example:

$ TERM=foo ssh localhost 'echo $TERM'
dumb
Kenster
  • 2,152
  • 16
  • 16