Prevent SSH client passing TERM environment variable to server?

$TERM is to tell applications what terminal they're talking to so they know how to talk to it.

Change it to a value supported by the remote host and that matches as closely as possible your terminal (screen).

Most Linux systems should at least have a screen terminfo entry. If not, screen implements a superset of vt100 and vt100 is universal. So:

TERM=screen ssh host

or

TERM=vt100 ssh host

If you do need the 256 color support, you could try xterm-256color which should be close enough (screen supports 256 colors the same way xterm does) and tell applications your terminal application supports 256 colors and tell them how to use them.

Or you can install the terminfo entry on the remote host.

infocmp -x | ssh -t root@remote-host '
  cat > "$TERM.info" && tic -x "$TERM.info"'

In my case I simply added an alias to my .zshrc (.bashrc if using bash) on my local desktop:

alias ssh='TERM=xterm ssh'

If you already use an alias, adjust it to include the Environment assignment.


Changing $TERM might work, but I don't suggest this, it's only a workaround instead of a solution.

When I encounter this problem on my systems, I fix it by installing support for the most common terminal types to the remote system:

  • yum install ncurses-base for screen-256color on CentOS
  • yum install ncurses-term for screen-256color-bce on CentOS
  • apt install ncurses-base for both screen-256color and screen-256color-bce on Debian, Ubuntu and Mint

The ncurses-related packages also provide support for a lot of other terminals, and they are also available on all other large distributions. (But for my use-case and your question this should be enough info)