Stop Losing Your Work:  The Essential Guide to Bulletproof VPS Connections
Technology Featured

Stop Losing Your Work: The Essential Guide to Bulletproof VPS Connections

By Max Hinrichs

Picture this: You’re vibeservering and editing code directly on your server with Claude Code. You’re in the middle of implementing a new feature when your mobile phone changes wifi and disconnects. Your SSH connection is dead, Claude Code has terminated, and you’ve code that’s halfway changed.

When accessing your servers from mobile devices, this can easily happen. WiFi drops, devices sleep, networks change, and suddenly important work vanishes. The solution isn’t better internet, but using the right tools to make your connections resilient.

Here’s how SSH, mosh, and tmux work together to eliminate connection anxiety forever.

Understanding Your Options

SSH: The Foundation

SSH is what everyone starts with, the standard way to connect to servers. It works perfectly until something goes wrong.

Pros:

  • Installed everywhere by default
  • Secure and reliable on stable connections
  • Hardly any extra setup required

Cons:

  • Dies when your connection drops
  • Kills all running processes when disconnected
  • Laggy on slow connections

Mosh: The Network-Resilient Connection

Mosh keeps your connection alive even when your network changes or drops temporarily.

Pros:

  • Survives network changes and brief disconnections
  • Shows keystrokes instantly (no typing lag)
  • Automatically reconnects when network returns

Cons:

  • Requires installation on both client and server
  • Uses more bandwidth than SSH
  • Can’t forward ports or transfer files
  • Needs UDP ports open (firewall configuration)

tmux: The Persistent Workspace

tmux creates sessions that survive complete disconnections - your work keeps running even when you’re offline.

Pros:

  • Sessions survive total disconnection
  • Resume exactly where you left off
  • Multiple windows and panes in one session
  • Share sessions with team members
  • Works with any connection method

Cons:

  • Uses extra memory on the server
  • Sessions can accumulate if not managed
  • Requires installation on the server

Setting Up Your Connection Stack

Installing mosh

On your VPS (Ubuntu/Debian):

sudo apt update
sudo apt install mosh

On your local machine:

# macOS
brew install mosh

# Ubuntu/Linux
sudo apt install mosh

Configure your VPS firewall:

# Ubuntu with ufw
sudo ufw allow 60000:61000/udp

If you’re using Hetzner Cloud, also add a firewall rule in their web console for UDP ports 60000-61000.

Installing tmux

On your VPS:

# Ubuntu/Debian
sudo apt install tmux

# CentOS/RHEL  
sudo yum install tmux

tmux runs on your server, so you only need to install it there.

When to Use Each Tool

SSH Alone: Quick and Simple Tasks

Perfect for basic server maintenance when you have a stable connection:

ssh user@your-vps
sudo systemctl restart nginx
sudo apt update
exit

SSH + tmux: Long Tasks on Stable Networks

When you need persistence but have reliable internet:

ssh user@your-vps
tmux new -s backup
./backup-database.sh
# Ctrl+b d to detach - backup continues running

mosh Alone: Mobile and Unreliable Networks

When you need connection resilience but doing shorter tasks:

mosh user@your-vps
# Network can drop and reconnect seamlessly
# But processes still die if you disconnect completely

mosh + tmux: Maximum Protection

For serious work where you can’t afford to lose progress:

mosh user@your-vps
tmux new -s project
# Survives network issues AND complete disconnections

Essential tmux Commands

Once connected, these commands manage your persistent sessions:

# Session management
tmux new -s name          # Create named session
tmux ls                   # List active sessions  
tmux attach -s name       # Reconnect to session
tmux kill-session -s name # End session

# Inside tmux (Ctrl+b prefix)
Ctrl+b d        # Detach (session keeps running)
Ctrl+b c        # New window
Ctrl+b %        # Split pane vertically  
Ctrl+b "        # Split pane horizontally
Ctrl+b arrows   # Navigate between panes

Pro Tips for Smooth Operations

Name your sessions meaningfully:

tmux new -s client-migration
tmux new -s database-backup
# Much clearer than generic session numbers

Create a connection alias:

# In your ~/.bashrc or ~/.zshrc
alias vpsmosh="mosh user@your-server-ip"

# Then just type: vpsmosh

Quick session management:

# Attach to last session or create new
tmux new-session -A -s main

# List sessions with more detail
tmux ls -F "#{session_name}: #{session_windows} windows"

Set up this stack once, and never lose work to connection problems again!