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.


$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

$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?

  • 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
  • 1
    As @grawity explained, it's special - it will be set no matter what AcceptEnv is set to. – l0b0 Jun 25 '14 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.