The way shown in https://ghostty.org/docs/help/terminfo does not work
infocmp -x xterm-ghostty | ssh YOUR-SERVER -- tic -x -
use this instead:
infocmp -Crx xterm-ghostty | ssh YOUR-SERVER -- tic -x -
-C tells infocmp to use termcap names, and the -r option tells it to translate terminfo capabilities to termcap format.
https://unix.stackexchange.com/questions/291412/how-can-i-use-terminfo-entries-on-freebsd