How to Prevent SSH Session Timeout on Solaris Servers: Client and Server Configuration Guide


2 views

Many developers working with Solaris servers face the frustrating issue of SSH sessions timing out during periods of inactivity. Whether you're using Ubuntu, another Solaris machine, or Windows with PuTTY as your client, the problem persists when connecting to Solaris servers. This becomes particularly disruptive when you step away for meetings or lunch breaks, only to return to frozen terminals.

SSH session timeouts typically occur due to two main factors:

  • Server-side TCP keepalive settings
  • Client-side connection configurations
  • Network infrastructure (firewalls, routers) dropping idle connections

For Linux/Unix clients (including Ubuntu and Solaris), add these to your ~/.ssh/config:

Host solaris-server
    HostName your.solaris.server
    User yourusername
    ServerAliveInterval 60
    ServerAliveCountMax 5
    TCPKeepAlive yes

For Windows PuTTY users:

  1. Load your session in PuTTY
  2. Navigate to Connection → Sending of null packets to keep session active
  3. Set "Seconds between keepalives" to 60

On the Solaris server, modify the SSH daemon settings in /etc/ssh/sshd_config:

# Solaris SSH Server Configuration
ClientAliveInterval 300
ClientAliveCountMax 3
TCPKeepAlive yes

After making changes, restart the SSH service:

svcadm restart ssh

For persistent sessions that survive disconnections:

# Install tmux on Solaris
pkg install tmux

# Basic usage
tmux new -s devsession
# Detach with Ctrl+b then d
# Reattach with:
tmux attach -t devsession

If timeouts persist, check intermediate devices:

# Check for TCP connection drops
dtrace -n 'tcp:::accept-established { @[args[3]->tcps_raddr] = count(); }'
dtrace -n 'tcp:::receive { @[args[3]->tcps_raddr] = count(); }'

For environments where you can't modify server configurations, consider Mosh:

# On client machines
pkg install mosh  # Linux/BSD
brew install mosh # macOS

# Connection command
mosh user@solaris-server

Many developers working with Solaris systems encounter SSH session timeouts regardless of their client platform - whether it's Ubuntu, another Solaris machine, or Windows with PuTTY. This typically occurs after periods of inactivity (like during lunch breaks), forcing you to recreate carefully configured terminal sessions.

SSH session timeouts can originate from multiple layers:

  1. Solaris server-side TCP keepalive settings
  2. SSH server configuration (sshd_config)
  3. Client-side SSH configuration
  4. Network equipment between client and server

1. Modifying sshd_config:

Edit /etc/ssh/sshd_config:

# Keep SSH connections alive
ClientAliveInterval 300
ClientAliveCountMax 3
TCPKeepAlive yes

This sends keepalive packets every 300 seconds (5 minutes), and will disconnect after 3 failed attempts.

2. System-wide TCP settings:

# Add to /etc/default/inetinit
TCP_KEEPALIVE_ABORT_THRESHOLD=1200
TCP_KEEPALIVE_INTERVAL=300

For OpenSSH clients (Linux, macOS, WSL):

Edit ~/.ssh/config:

Host solaris-dev
    HostName solaris-dev.example.com
    User developer
    ServerAliveInterval 60
    ServerAliveCountMax 10

For PuTTY (Windows):

In Connection section:

  • Set "Seconds between keepalives" to 60
  • Enable "Enable TCP keepalives"

For persistent sessions that survive even network interruptions:

# Start a named tmux session
tmux new -s dev_session

# Or with screen
screen -S dev_session

Then detach with Ctrl-b d (tmux) or Ctrl-a d (screen) and reattach later.

If timeouts persist, check:

  1. Network equipment (firewalls, NAT devices) may have their own timeout settings
  2. Compare behavior with telnet solaris-dev.example.com 22 to isolate SSH-specific issues
  3. Use tcpdump to verify keepalive packets are being sent/received
  • ✅ Server: sshd_config modifications
  • ✅ Server: TCP keepalive parameters
  • ✅ Client: SSH keepalive settings
  • ✅ Optional: Terminal multiplexer setup