I use ’tmux’ on anything that runs it, from FreeBSD, macOS and Linux.

On some of my Linux servers, noticeably openSUSE ones, when I connect to them via SSH, I would receive the following warning:

...
Have a lot of fun...
warning: Could not set up terminal.
warning: TERM environment variable set to 'tmux-256color'.
warning: Check that this terminal type is supported on this system.
warning: Using fallback terminal type 'ansi'.

What worse is that, when I switch to root account, the backspace key doesn’t work correctly. For example, hitting backspace will produce a space instead.

How can I fix this? By setting the variable TERM='xterm'.

➜ export TERM='xterm'
➜ ssh tc2
...
Have a lot of fun...
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
...

Some also suggested to set the default value in the ~/.tmux.conf as the following:

set -g default-terminal "xterm"

And how did I find this out? Of course, by searching for similar problem on the internet. Full credit goes to the owner of the article below.

Reference: