Strovent SystemsSign in
Reference

xterm-ghostty or xterm-kitty not found after SSH: fix TERM and terminfo

Ghostty and kitty set TERM to their own name, and SSH sends it to hosts that lack that terminfo entry. Copy the entry to the host or send TERM=xterm-256color.

'xterm-ghostty': unknown terminal type.
Error opening terminal: xterm-kitty.
WARNING: terminal is not fully functional

You logged in with SSH from the Ghostty or kitty terminal, and clear, vim, top, less or htop on the host print one of these lines. Arrow keys or colors may also misbehave.

Why it happens

Every terminal program sets the TERM variable to the name of its description in the terminfo database. Ghostty uses xterm-ghostty, and kitty uses xterm-kitty. Both ship that description with the app on your own computer.

When ssh opens a session with a terminal, it always sends TERM to the host; the ssh_config manual says the protocol requires it. Programs on the host then look up xterm-ghostty or xterm-kitty in the host's own terminfo database. If the host has no entry with that name, they fail with the messages above. Your login works; only programs that need the terminal description are affected.

The Ghostty documentation notes that its entry is part of ncurses from version 6.5-20241228. Hosts with an older ncurses do not have it. For kitty, many Linux distributions have a kitty-terminfo package.

Check what the host received:

echo $TERM

Fix 1: copy the entry to the host

Run this on your own computer, in the Ghostty or kitty window. It prints the local description and compiles it on the host.

For Ghostty:

infocmp -x xterm-ghostty | ssh [email protected] -- tic -x -

For kitty:

infocmp -a xterm-kitty | ssh [email protected] tic -x -o \~/.terminfo /dev/stdin

Without root access, tic writes the entry to ~/.terminfo on the host. The general method, and why that folder matters, is in Unknown terminal type or "Error opening terminal" when you use tmux, screen or SSH. You do this once per host and user.

The Ghostty documentation says the infocmp bundled with macOS before Sonoma is too old for this and fails with Illegal character messages; use a newer ncurses infocmp instead.

Fix 2: let the terminal copy it for you

Both terminals have an SSH wrapper that installs the entry when you connect:

  • Ghostty: ghostty +ssh -- [email protected]. The documentation says it installs the entry with tic the first time and falls back to TERM=xterm-256color if that fails. It is new in Ghostty 1.4; version 1.3 does not have it. In both versions, setting shell-integration-features = ssh-terminfo in Ghostty's configuration makes plain ssh in the shell install the entry for you.
  • kitty: kitten ssh [email protected]. It copies the terminfo files and takes the same arguments as ssh.

Fix 3: send a common TERM name instead

If you cannot or do not want to install anything on the host, send a name every host knows. In ~/.ssh/config on your computer:

Host host.example.com
  SetEnv TERM=xterm-256color

This needs OpenSSH 8.7 or later on your computer; the 8.7 release notes added the ability for SetEnv to override TERM. The host then uses its xterm-256color entry. Colors and most features work, but features beyond xterm's, such as Ghostty's styled underlines, do not. Only add it for hosts that lack the entry. For a single session, export TERM=xterm-256color on the host does the same.

The error appears only with sudo

On your own computer, the terminals point programs at their private terminfo folder with the TERMINFO variable, and sudo often removes it. kitty's documentation suggests keeping it with this line in sudo visudo:

Defaults env_keep += "TERM TERMINFO"

Ghostty can do the same through shell-integration-features = sudo.

On a remote host, programs find an entry copied into ~/.terminfo through the HOME variable. Commands run with sudo -i get the other user's HOME and do not see it. Install the entry system-wide, or use Fix 3.

Sources

Spotted a mistake? Email [email protected].