How to Fix Backspace and Tab Completion Issues in SSH Client 3.2.9 When Connecting to Unix Servers


2 views

When using SSH Client version 3.2.9 to connect to a Unix server, several key terminal functions behave unexpectedly:

  • Backspace produces ^H instead of erasing characters (though Shift+Backspace works)
  • Tab completion doesn't show suggestions
  • The tilde (~) doesn't resolve to home directory

The issue stems from improper terminal settings being negotiated during SSH connection establishment. The stty istrip in your local.profile is particularly problematic as it strips input characters to 7 bits.

Try these diagnostic commands after connecting:

stty -a
stty sane
stty erase ^?

Option 1: Modify your local.profile

# Replace stty istrip with these settings:
stty erase ^? intr ^C kill ^U susp ^Z
stty -istrip -inlcr -icrnl -ixon -ixoff

Option 2: Client-side SSH configuration

Add this to your SSH client config (~/.ssh/config):

Host *
    Protocol 2
    EscapeChar ~
    ServerAliveInterval 60
    TCPKeepAlive yes
    SendEnv LANG LC_*
    ForwardX11Trusted yes
    ForwardAgent yes
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

Ensure your shell initialization files are properly sourced. For bash users:

if [ -f ~/.bashrc ]; then
    . ~/.bashrc
fi

For csh/tcsh users:

if (-f ~/.cshrc) then
    source ~/.cshrc
endif

After making changes, verify terminal behavior with:

printf "Test backspace: abc\b \b"

Check tab completion by typing partial commands (like ls /usr/loc then Tab). Test home directory resolution:

echo ~
cd ~
pwd

When working with legacy SSH clients like version 3.2.9 on Solaris systems, you might encounter several keyboard mapping issues:

# Common symptoms:
1. Backspace generates ^H instead of deleting characters
2. Shift+Backspace works but regular Backspace doesn't
3. Tab completion fails to suggest filenames
4. ~ doesn't resolve to home directory

The issues stem from three main sources:

  1. Incorrect TERM environment variable setting
  2. Missing or improper stty configurations
  3. Shell initialization files not properly sourced

First verify and set your terminal type:

# Check current TERM setting
echo $TERM

# Set appropriate terminal type (for most modern clients)
export TERM=xterm-256color

Add these lines to your local.profile:

# Fix backspace mapping
stty erase '^?'  # Maps backspace to delete
stty intr '^C'   # Ensures Ctrl-C works
stty susp '^Z'   # Ensures Ctrl-Z works

For csh/tcsh shells, ensure your local.cshrc contains:

# Enable tab completion
set autolist
set complete = enhance

# Alternative for bash users
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

For proper ~ expansion, add to your local.profile:

# Ensure proper home directory resolution
export HOME=$(getent passwd $USER | cut -d: -f6)
alias cdh="cd ~"  # Optional shortcut

Test your configuration:

# Test backspace
echo "Type something and press backspace"

# Test tab completion
cd /etc
ls -l <press tab>

# Test home directory
echo ~

For permanent changes, update all relevant files:

# Add to local.profile
cat << EOF >> ~/local.profile
# Terminal fixes
export TERM=xterm-256color
stty erase '^?'
stty intr '^C'
stty susp '^Z'
EOF

Remember to source your updated files or restart your SSH session for changes to take effect.