SSH Backspace Not Working? It's a terminfo Problem

SSH Backspace Not Working? It's a terminfo Problem

You install a shiny new terminal app, everything works great locally, then you SSH into a remote server and suddenly Backspace stops working. Instead of deleting characters, it prints spaces. Here's why it happens and how to fix it with a single command.

Symptoms

  • Everything works fine locally
  • After SSH-ing into a remote server, Backspace acts like Space
  • Other special keys (arrow keys, Home/End) may also behave unexpectedly

The Cause: What Is terminfo?

There are many terminal emulators out there: macOS Terminal.app, iTerm2, Ghostty, Alacritty, WezTerm, and more. Each handles key input, colors, and cursor movement slightly differently.

terminfo is a database that defines these per-terminal differences. The OS reads the TERM environment variable to determine which terminal you're using, then looks up the corresponding terminfo entry to map each key to the correct action.

The problem arises during SSH. Your local TERM value gets passed to the remote server as-is. If the remote server doesn't have the terminfo entry for that terminal, it can't properly interpret key sequences.

A Concrete Example

Here's what happened to me:

1. SSH from MacBook into Mac mini using Ghostty terminal

2. SSH forwards TERM=xterm-ghostty to the Mac mini

3. Mac mini has no terminfo entry for xterm-ghostty

4. Mac mini can't interpret the Backspace key sequence

5. Result: pressing Backspace inserts a space instead of deleting

This isn't Ghostty-specific. Any relatively new terminal app can trigger the same issue.

The Fix: One Command

Copy the terminfo from where it exists (local) to where it doesn't (remote):


infocmp -x xterm-ghostty | ssh your-server tic -x -

That's it. Here's what each part does:

CommandRole
infocmp -x xterm-ghosttyExport the Ghostty terminfo as text on the local machine
`\`Pipe the output to the next command
ssh your-server tic -x -Install it on the remote server via tic (terminfo compiler)

Reconnect via SSH, and Backspace works again.

"Can't I Just Change TERM?"

You could set TERM=xterm-256color as a workaround, either in .bashrc or your SSH config. It works, but you lose terminal-specific features (extended colors, special sequences, etc.). Installing the actual terminfo is the cleaner solution.

Takeaways

  • When keys misbehave on a remote server after SSH, suspect terminfo first
  • infocmp | ssh ... tic is all it takes
  • If you have multiple servers, run it once on each

This can happen every time you switch terminal apps, but once you know the cause, the fix is trivial.