$ recombobulate _
home / tips / use-mosh-instead-of-ssh-to-keep-remote-claude-code-connections-alive
0

Use mosh Instead of SSH to Keep Remote Claude Code Connections Alive

bagwaa @bagwaa · Mar 26, 2026 · Configuration
use-mosh-instead-of-ssh-to-keep-remote-claude-code-connections-alive

tmux keeps your Claude Code session alive when your terminal closes. But if you're accessing a remote machine over SSH, the connection itself can drop — switching networks, a laptop going to sleep, or moving between wifi and mobile kills the link even if tmux kept the session intact.

mosh solves the connection layer, not just the session layer.

# Install mosh
brew install mosh              # macOS
sudo apt install mosh          # Ubuntu/Debian

# The server needs mosh installed too
ssh user@your-server.com "sudo apt install mosh -y"

# Connect with mosh instead of SSH
mosh user@your-server.com

# Once connected, start tmux for session persistence
tmux new -s work
claude  # start Claude Code inside tmux inside mosh

mosh uses UDP rather than TCP, so it survives roaming between networks, tolerates packet loss gracefully, and reconnects automatically after your laptop wakes up. Your session is waiting exactly where you left it.

This is particularly useful when working from a phone or tablet: SSH drops the moment your network changes or the screen locks. mosh stays connected.

The combination of both tools is the best setup for remote Claude Code work: mosh handles connection resilience so you never get cut off, tmux handles session persistence so you never lose your work. Neither alone gives you both.

Use mosh for the connection and tmux for the session — together they make remote Claude Code nearly indestructible.


via @odd_joel

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Switch to the Stable Update Channel with autoUpdatesChannel

The autoUpdatesChannel setting pins Claude Code to a stable release track that skips versions with major regressions.

bagwaa @bagwaa · 2 hours ago
0
Set Claude's Response Language with the language Setting

The language setting makes Claude respond in your preferred language by default, across every session and project.

bagwaa @bagwaa · 2 hours ago
0
Customize or Remove Claude's Git Attribution with the attribution Setting

The attribution setting lets you customize or completely remove Claude's Co-Authored-By trailer from git commits and pull requests.

bagwaa @bagwaa · 2 hours ago