ssh from screen leads to unknown terminal error

I’m trying to make an ssh connection (via lsh) from one Ubuntu host to another from within screen. If I try to run mc right after that I get the following error:

Unknown terminal: screen-256color-s
Check the TERM environment variable.
Also make sure that the terminal is defined in the terminfo database.
Alternatively, set the TERMCAP environment variable to the desired
termcap entry.

The question is – who’s causing this failure? Is it local host? remote? some package missing (which?), something not done by lsh-server? or client?

Just to be clear – I don’t want workarounds like “TERM=xterm mc”, I want to be able to use visual themes which support 256 colors on the (remote) console.

Asked By: god


Just set another TERM, For example






Maybe an export TERM helps too.

The TERM variable is used by curses and termcap programs, such as mc or dialog, to read the terminal escape codes from the terminfo/termcap databases, where the command is executed, so in your case in the remote system.

To support the “screen-256color-s” TERM type this terminal type must be installed in the database.

As a good starting point read man 5 terminfo.

Answered By: ikrabbe

GNU screen is setting $TERM locally, and ssh is passing that value to the remote side. There are a few things you can do.

  • Detect the screen-256-color-s on the remote side and set to a more sane. From that you can have case $TERM in screen-256*) TERM=screen;; esac.
  • From the local side, have screen set the terminal. In your ~/.screenrc file have: term screen.
  • If you have a screen command to open the ssh call, then add a -T option: screen -T screen ssh user@host
  • In you local ~/.bashrc, set the terminal if it detects the incompatible one similar to the remote side one above.
Answered By: Arcege

Finally, I’ve managed to figure out “obvious” package which supply screen-256-color-s (got to be installed on remote machine):

sudo apt install ncurses-term

fixed the problem for me: nice 256 colors and no need for ugly workarounds with environment variables. Hooray! 🙂

Answered By: god