diff options
Diffstat (limited to 'content/notes/ghostty-ssh-issue.md')
| -rw-r--r-- | content/notes/ghostty-ssh-issue.md | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/content/notes/ghostty-ssh-issue.md b/content/notes/ghostty-ssh-issue.md new file mode 100644 index 0000000..45c82ac --- /dev/null +++ b/content/notes/ghostty-ssh-issue.md @@ -0,0 +1,41 @@ ++++ +title = "在 Ghostty 中使用 SSH 的问题" +date = 2026-02-05 15:44:45 +tags = ["运维", "Linux"] ++++ + +## 问题描述 + +我的主力终端模拟器是 [Ghostty](https://ghostty.org/),直接 SSH 到远程服务器可能遇到一些问题,比如无法打开 `htop`、使用 `systemctl` 查看服务的状态时会提示终端 `not fully functional`,一些颜色的显示也会有问题。 + +调查后发现原因来自 Ghostty 的 Terminfo(终端信息)。简单来说,Terminfo 是一种很老的格式,许多终端应用会通过读取 Terminfo 来确定终端的能力;如果应用程序不认识这个终端,可能会认为当前运行程序的终端缺少必要的能力,继而无法正常运行。 + +Ghostty 的终端信息是 `xterm-ghostty`,如果 SSH 到一台没有 Ghostty 的终端信息条目的机器上,可能会得到这样的提示: + +```shell +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 的信息发送到远程服务器上。 + +```shell +infocmp -x xterm-ghostty | ssh YOUR-SERVER -- tic -x - +``` + +## 参考资料 + +- https://ghostty.org/docs/help/terminfo#ssh +- https://en.wikipedia.org/wiki/Terminfo |
