ssh from screen leads to unknown terminal error

Just set another TERM, For example

TERM="rxvt"

or

TERM="xterm"

or

TERM="vt102"

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.


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! :)


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.