When working with remote servers via SSH, you might encounter terminal compatibility issues if your local $TERM
value (e.g., konsole-256color
) isn't available on the remote machine. This can lead to display issues or limited functionality in terminal applications.
The most straightforward way is to use SSH's SendEnv
feature. Add this to your ~/.ssh/config
:
Host *
SendEnv TERM
Then specify your fallback terminal type:
ssh user@host -o "SendEnv=TERM" TERM=xterm-256color
You can override the terminal type completely during connection:
ssh -t user@host "export TERM=xterm-256color; bash --login"
The -t
flag forces pseudo-terminal allocation.
For regular connections, add this to your SSH config:
Host my-remote-server
HostName example.com
User myuser
RequestTTY yes
RemoteCommand export TERM=xterm-256color; bash -l
Verify the terminal type after connecting:
echo $TERM
infocmp
For machines with minimal terminfo databases, consider:
ssh user@host "TERM=xterm; export TERM; exec bash"
Be aware that some SSH servers are configured with AcceptEnv
restrictions. Check with:
ssh -v user@host
Look for "Server accepts environment" in the debug output.
When working with SSH connections between heterogeneous systems, terminal compatibility issues frequently arise. A common scenario occurs when your local machine uses advanced terminal types like konsole-256color
or xterm-256color
, but remote systems lack these terminfo definitions.
# Local machine check
$ echo $TERM
konsole-256color
# Remote machine error
$ ssh user@remote
Warning: No entry for terminal type "konsole-256color"
The most reliable approach is modifying your SSH client configuration:
# ~/.ssh/config
Host *
SendEnv TERM
RequestTTY yes
SetEnv TERM=xterm-256color
Alternatively, for one-time connections:
ssh -o "SendEnv TERM" -t user@remote 'export TERM=xterm-256color; exec $SHELL'
Ensure the remote server's sshd_config
allows client environment variables:
# /etc/ssh/sshd_config
AcceptEnv TERM
When you can't modify server configuration, consider these alternatives:
# Using tmux/screen as a wrapper
ssh user@remote -t 'TERM=screen-256color tmux new -A -s main'
# Alias for convenience
alias sshsafe='ssh -t user@remote "TERM=xterm-256color bash"'
After implementation, verify the environment:
ssh user@remote 'echo $TERM'