Add this to your ~/.ssh/config on Your local pc:
Host *
SendEnv TERM
SetEnv TERM=xterm-256color
This ensures every SSH session tells the remote side “I am xterm-256color” instead of xterm-ghostty.
Ghostty lets you configure the $TERM it sets. In your Ghostty config file (on NixOS, usually ~/.config/ghostty/config), add:
term = xterm-256color
Now every new Ghostty window reports itself as xterm-256color, which is understood by tmux and almost all servers.