Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Phone SSH sessions usually disconnect because a standard SSH terminal depends on one live TCP connection. A Wi-Fi-to-cellular handoff, a short loss of signal, an idle firewall timeout, or a phone suspending its terminal app can interrupt it. OpenSSH keepalives can help with some idle-timeout problems, but they cannot make SSH roam to a new network address. For roaming interactive shells, use Mosh; to keep remote work running after you reconnect, use tmux.

Why does SSH disconnect when your phone switches networks?

SSH carries a normal terminal session over TCP. If your phone changes networks, loses connectivity briefly, or gets a different IP address, the existing TCP connection may no longer have a working path to the server. SSH keepalives can detect an unresponsive connection and sometimes prevent an intermediary from expiring an idle one, but they do not migrate the existing connection to a new address. The Mosh project is designed for roaming and intermittent connectivity.

Wi-Fi or cellular handoff

If the drop happens during a Wi-Fi-to-cellular switch or a weak-signal interruption, suspect a broken network path rather than an idle timeout. Ordinary SSH does not resume its TCP session on the new path. Mosh is the directly relevant option if the host and network can support it.

Phone locks or terminal app goes to the background

If SSH drops only after the screen locks or you switch apps, first test with the terminal visible. Then check the specific terminal app’s documentation and your phone’s battery and background-execution settings. Background behavior varies by app, operating system version, device manufacturer, and user settings; there is no single setting that applies to every iPhone or Android device.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Disconnect after a predictable idle period

If the phone remains on the same network and the session closes after a repeatable period of inactivity, an idle timeout in a firewall or NAT device is a possibility. A client keepalive may keep some idle paths active, depending on that intermediary’s policy.

Terminal stops responding without a clear disconnect

Check the mobile client’s connection log and, if available, its verbose diagnostics. Blink’s documentation describes using ssh -vvv to increase SSH diagnostic output; the equivalent steps vary across mobile apps. Server logs may also help distinguish an SSH failure from an app or network problem.

Rank #2
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

How do I keep SSH alive on my phone?

For an OpenSSH client, add a host entry like this to its SSH configuration:

Host myserver
    ServerAliveInterval 30
    ServerAliveCountMax 3

This is an illustrative starting point, not a universal setting or a guarantee. ServerAliveInterval asks the client to request a response through the encrypted channel after the configured period with no data from the server. ServerAliveCountMax sets how many unanswered checks the client tolerates. The OpenBSD ssh_config(5) manual documents defaults of 0 for the interval (disabled) and 3 for the count. It also gives an example: with a 15-second interval and the default count of 3, SSH disconnects after approximately 45 seconds if the server remains unresponsive. That example illustrates failure detection; it is not a recommended value for every connection.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Mobile SSH apps may expose equivalent options under different names, or may not offer them. Server-side ClientAliveInterval and ClientAliveCountMax are separate sshd settings: they govern checks initiated by the server, not the phone’s client configuration. Increasing timeout values indiscriminately can delay detection of a dead connection without fixing the underlying network change.

  • Use client keepalives to address some idle-path timeouts or detect a connection that has stopped responding.
  • Do not expect keepalives to restore a broken radio link, move a TCP connection to a new IP address, or prevent the phone from suspending its terminal app.

When should I use Mosh instead of SSH?

Use Mosh when you need an interactive shell that can cope with temporary connectivity loss or a change of network address. Mosh uses SSH for initial authentication and to start mosh-server; the interactive terminal then runs over UDP. The project documentation describes a default UDP port range of 60000–61000. The host needs the Mosh server component, your phone needs a Mosh-capable client, and the network must allow the selected UDP port or range. If UDP is blocked, Mosh may not work on that network.

Rank #4
Sale
Samsung Galaxy S26 Ultra, Unlocked Android Smartphone, 512GB, Black
  • PRIVACY DISPLAY: Automatically hide your screen from those beside you. The built-in privacy display can be preset¹ to turn on when receiving notifications, typing passwords, or using specific apps
  • TYPE IT IN. TRANSFORM IT FAST: Enhance any shot in seconds on your smartphone by using Photo Assist² with Galaxy AI.³ Add objects, restore details, or apply new styles by simply typing or tapping
  • NIGHTS, CAPTURED CLEARLY: From gigs to city lights, record and capture moments after dark with clarity using Nightography so your photos and videos stay crisp and clear on your Samsung Galaxy
  • MAKE IT. EDIT IT. SHARE IT: Turn everyday moments into something personal with creative tools built right into your mobile phone, whether it’s a special contact photo, custom wallpaper, an invitation or more⁴
  • HELP THAT KEEPS UP: Stay in the moment while Now Nudge with Galaxy AI helps you respond faster and stay organized with smart suggestions⁵ that appear exactly when you need them on your phone

Mosh is not a drop-in replacement for every SSH task. Keep ordinary SSH for workflows such as port forwarding or file transfer, and check whether the client supports the features your workflow requires. SSH still performs Mosh’s initial login.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How can I stop a command from dying when my phone disconnects?

Run long-lived work inside a tmux session on the server. For example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Tracfone Moto g Play 2024 Prepaid Phone with a 1-Yr Plan Included
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Activating is easy, just 3 steps.
  • ACTIVATION Promotion: Includes 1500 min, 1500 texts & 1500 MB Data + add more as you need it
  • CAMERA SYSTEM: 50MP Quad Pixel camera. Capture sharper, more vibrant photos day or night with 4x the light sensitivity.
  • PERFORMANCE: Blazing-fast Qualcomm performance. Get the speed you need for great entertainment with a Snapdragon 680 processor and 4GB of RAM.
  • 64GB built-in storage. Get plenty of room for photos, movies, songs, and apps. Made for US
  1. Start a named session on the remote host: tmux new -s work.
  2. Run the command inside that session.
  3. After reconnecting, reattach with tmux attach -t work.

The OpenBSD tmux(1) manual describes sessions as persistent across accidental disconnection. Because tmux runs on the server, the session and work started inside it can remain available independently of the phone’s terminal connection. tmux does not keep the SSH TCP stream connected, restore input typed while disconnected, or protect a command that you started outside the tmux session. For commands started elsewhere, whether they survive a terminal or connection closure depends on how the command handles hangups and terminal shutdown.

Which fix matches the problem?

Remedy What it addresses Server setup Survives a network handoff? Keeps remote work running?
OpenSSH client keepalives Some idle timeouts and detection of an unresponsive path Usually no server change for client-side settings; server-side settings are separate No No, not by itself
Mosh Interactive terminal roaming and intermittent connectivity Yes: mosh-server and reachable UDP Designed to Preserves the interactive remote shell through supported interruptions
tmux Remote terminal and work persistence after disconnection Yes: tmux must be available on the host No; reconnect separately Yes, when the work runs inside its session

Choose based on the failure and the outcome you need: keepalives are for some quiet connections, Mosh is for interactive roaming, and tmux is for work that must remain available after a disconnect. They address different problems and can be used together where appropriate.

Quick Recap

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.