在 Ghostty 中使用 SSH 的问题
问题描述
我的主力终端模拟器是 Ghostty,直接 SSH 到远程服务器可能遇到一些问题,比如无法打开 htop、使用 systemctl 查看服务的状态时会提示终端 not fully functional,一些颜色的显示也会有问题。
调查后发现原因来自 Ghostty 的 Terminfo(终端信息)。简单来说,Terminfo 是一种很老的格式,许多终端应用会通过读取 Terminfo 来确定终端的能力;如果应用程序不认识这个终端,可能会认为当前运行程序的终端缺少必要的能力,继而无法正常运行。
Ghostty 的终端信息是 xterm-ghostty,如果 SSH 到一台没有 Ghostty 的终端信息条目的机器上,可能会得到这样的提示:
missing or unsuitable terminal: xterm-ghostty
Error opening terminal: xterm-ghostty.
WARNING: terminal is not fully functional
解决方案
根据 Ghossty 的文档,解决方案有两个,我使用的方法是修改环境变量,把 TERM 设置为另一个被广泛支持的终端,比如 xterm-256color。可以在 .ssh/config 里这样写。
Host example
TERM=xterm-256color
这样远程服务器就会把 Ghostty 视作 256color,不会认为 Ghostty 缺少某些功能。
还有一种方法是把 Ghostty 的信息发送到远程服务器上。
infocmp -x xterm-ghostty | ssh YOUR-SERVER -- tic -x -
参考资料
2026-02-05