Back to Blog

Keeping SSH Sessions Alive on iOS: How ProSSH Handles Backgrounding

| BudgetSoft | 3 min read | Guides

If you've used SSH on an iPhone before, you know the pain: switch to Safari to look something up, switch back, and your session is dead. The terminal is frozen. You reconnect, lose your context, and start over.

This happens because iOS suspends apps when they move to the background. The SSH connection goes quiet, the server stops hearing from the client, and eventually the connection times out.

ProSSH's keep-alive feature helps you stay connected.

How SSH connections drop

An SSH connection is a TCP socket. When the app is backgrounded, iOS suspends the process — no code runs, no network packets are sent. From the server's perspective, the client has gone silent.

Most SSH servers have a timeout configured. If the client doesn't send any data within that window (often 60-300 seconds), the server assumes the client is gone and closes the connection.

When you switch back to ProSSH, the TCP socket is still open on your end, but the server has already hung up. The session is dead.

What keep-alive does

SSH keep-alive sends small, invisible packets at regular intervals to tell the server "I'm still here." In ProSSH, you can configure the keep-alive interval — the number of seconds between packets.

When ProSSH is in the foreground, keep-alive packets flow regularly. This prevents the server from timing out, even during idle periods when you're reading output or thinking.

Configuring keep-alive in ProSSH

  1. Open Settings
  2. Find the Keep-Alive section
  3. Set your preferred interval (in seconds)

A good default is 30 seconds — frequent enough to keep most servers happy, but not so chatty that it wastes battery.

What about the background?

Here's the honest truth: iOS doesn't let apps maintain network connections indefinitely in the background. This is an iOS platform limitation, not a ProSSH limitation. No SSH client on iOS can keep a connection alive forever in the background.

What ProSSH does:

  • Keep-alive while foregrounded — your sessions stay alive as long as the app is on screen
  • Graceful reconnection — when a session does drop, reconnecting is fast since your host configuration is saved
  • Session state — your saved hosts, tunnels, and settings are always there when you return

Tips for longer sessions

Use a terminal multiplexer on the server. This is the real solution for long-running work:

# Start a tmux session
tmux new -s work

# Detach with Ctrl-B, then D
# Reattach after reconnecting:
tmux attach -t work

With tmux or screen, your remote session keeps running even when the SSH connection drops. When you reconnect, you reattach to exactly where you left off — command history, running processes, and all.

Lower the keep-alive interval if your server has aggressive timeouts. Try 15 seconds.

Keep ProSSH in the foreground for active work. If you need to check something in another app, use Split View on iPad to keep ProSSH visible.

Server-side configuration

If you control the server, you can also adjust the server's timeout settings in /etc/ssh/sshd_config:

ClientAliveInterval 60
ClientAliveCountMax 3

This tells the server to send its own keep-alive every 60 seconds and allow 3 missed responses before disconnecting. Combined with ProSSH's client-side keep-alive, this gives you a resilient connection.

Get ProSSH

Keep-alive settings are included in ProSSH. €14.99 on the App Store, one-time purchase.

Related posts