Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My ssh config file has accept env set as:

AcceptEnv LANG LC_*

I am a bit confused how when I ssh through some clients my TERM variable is set as xterm256-color, and other clients TERM is set as vt100. My .bashrc and /etc/profile do not have anything that is setting the TERM variable.

share|improve this question
up vote 2 down vote accepted

$TERM is special – it is not sent as an environment variable (which wouldn't make sense for non-Unix systems anyway), but rather as a special "terminal type" field when establishing a pseudo-terminal channel, per RFC 4254 § 6.2.

6.2. Requesting a Pseudo-Terminal

A pseudo-terminal can be allocated for the session by sending the following message.

uint32    recipient channel
string    "pty-req"
boolean   want_reply
string    TERM environment variable value (e.g., vt100)
uint32    terminal width, characters (e.g., 80)
uint32    terminal height, rows (e.g., 24)
uint32    terminal width, pixels (e.g., 640)
uint32    terminal height, pixels (e.g., 480)
string    encoded terminal modes
share|improve this answer
Exactly what I was looking for, thanks! – marcwho Jun 25 '14 at 14:10

$TERM is set by the terminal, that is, the parent process of the shell you are running locally. It is used by applications to determine what the capabilities of the terminal is, for example whether it supports colour. It's very useful to forward this to any other hosts you connect to, since otherwise they would lose this knowledge of the capabilities about the end user terminal.

See for example Prevent SSH client passing TERM environment variable to server?

share|improve this answer
I'm not sure I understand your answer. My question is: how is TERM set if AcceptEnv does not allow it to be set. If this is detected automatically, what process does the detection, is there documentation anywhere on this? – marcwho Jun 25 '14 at 13:15
As @grawity explained, it's special - it will be set no matter what AcceptEnv is set to. – l0b0 Jun 25 '14 at 13:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .