How to Connect to Your VDS Server via SSH (Complete Guide)
Step-by-step SSH connection guide for Linux VDS: PuTTY, Terminal, key-based authentication, Path Panel firewall rules, and security best practices.
Manage SSH sessions with Tmux and GNU Screen. Installation, window/pane management, detach/attach, session persistence, and comparison guide.
One of the biggest challenges when working on remote servers is SSH connection drops. When the connection is lost, running processes terminate. Tmux and GNU Screen are terminal multiplexers that solve this problem. This guide covers both tools and helps you understand when to use each.
When your SSH session drops:
Tmux and Screen keep sessions alive on the server side. Even if your connection drops, processes continue running in the background. When you reconnect, you pick up exactly where you left off.
Tmux is the more modern, actively developed tool. Screen is older and often comes pre-installed. Knowing both is useful.
sudo apt update
sudo apt install tmux -y
# Check version
tmux -V
sudo dnf install tmux -y
# or on older systems
sudo yum install tmux -y
# Start a new session
tmux
# Start a named session
tmux new-session -s myproject
# or shorthand
tmux new -s myproject
# Detach from session — processes keep running
# Ctrl+b, then d
# List existing sessions
tmux list-sessions
# or shorthand
tmux ls
# Reattach to a session
tmux attach-session -t myproject
# or shorthand
tmux attach -t myproject
# Attach to the last session
tmux attach
# Kill a session
tmux kill-session -t myproject
# Kill all sessions
tmux kill-server
All tmux commands start with a prefix key. Default prefix: Ctrl+b
After sending the prefix, press the command key:
| Command | Description |
|---|---|
Ctrl+b d | Detach from session |
Ctrl+b c | Create new window |
Ctrl+b n | Next window |
Ctrl+b p | Previous window |
Ctrl+b 0-9 | Switch to numbered window |
Ctrl+b , | Rename window |
Ctrl+b & | Close current window |
Ctrl+b % | Split vertically (right) |
Ctrl+b " | Split horizontally (below) |
Ctrl+b arrow keys | Navigate between panes |
Ctrl+b z | Toggle pane fullscreen |
Ctrl+b [ | Enter scroll mode |
Ctrl+b ? | Help screen |
# Create a new window inside tmux
# Ctrl+b, then c
# List windows
# Ctrl+b, then w
# Rename window
# Ctrl+b, then ,
# Close window
# Ctrl+b, then &
Panes let you split a single window into multiple terminals.
# Vertical split (side by side)
# Ctrl+b, then %
# Horizontal split (top/bottom)
# Ctrl+b, then "
# Navigate between panes
# Ctrl+b, then arrow keys
# Toggle pane fullscreen
# Ctrl+b, then z
# Close pane
# Ctrl+b, then x
# Resize pane
# Ctrl+b, then Ctrl+arrow keys
Create ~/.tmux.conf to customize tmux:
nano ~/.tmux.conf
# Change prefix to Ctrl+a (like Screen)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Enable mouse support
set -g mouse on
# Start window numbering at 1
set -g base-index 1
setw -g pane-base-index 1
# Customize status bar
set -g status-bg colour235
set -g status-fg white
set -g status-left '[#S] '
set -g status-right '%H:%M %d-%b-%y'
# Increase history limit
set -g history-limit 10000
# Reload configuration
tmux source-file ~/.tmux.conf
# or inside tmux:
# Ctrl+b, then :source-file ~/.tmux.conf
Screen is older than tmux but often comes pre-installed on many systems.
# Ubuntu/Debian
sudo apt install screen -y
# CentOS/AlmaLinux
sudo dnf install screen -y
# Start a new session
screen
# Start a named session
screen -S myproject
# Detach from session
# Ctrl+a, then d
# List sessions
screen -ls
# Reattach to session
screen -r myproject
# Attach by ID if multiple sessions exist
screen -r 12345.myproject
# Kill a session
# Inside screen: Ctrl+a, then k
# From outside:
screen -X -S myproject quit
Screen's prefix key is Ctrl+a:
| Command | Description |
|---|---|
Ctrl+a d | Detach from session |
Ctrl+a c | Create new window |
Ctrl+a n | Next window |
Ctrl+a p | Previous window |
Ctrl+a " | Window list |
Ctrl+a A | Rename window |
Ctrl+a S | Horizontal split |
| `Ctrl+a | ` |
Ctrl+a Tab | Switch between panes |
Ctrl+a [ | Scroll mode |
Ctrl+a ? | Help |
| Feature | Tmux | Screen |
|---|---|---|
| Active development | Yes | No |
| Vertical split | Yes | Yes (newer versions) |
| Mouse support | Yes | Limited |
| Configuration | Powerful | Basic |
| Pre-installed | No | Often yes |
| Learning curve | Medium | Low |
| Scripting support | Excellent | Good |
# Start a new session
tmux new -s build
# Run a long command
make all
# Detach — process continues
# Ctrl+b d
# Check back later
tmux attach -t build
# Start session
tmux new -s monitoring
# Vertical split
# Ctrl+b %
# Monitor CPU in left pane
htop
# Switch to right pane (Ctrl+b right arrow)
# Monitor disk I/O
iostat -x 2
# Add to ~/.bashrc or ~/.bash_profile
if command -v tmux &> /dev/null && [ -z "$TMUX" ]; then
tmux attach -t default || tmux new -s default
fi
Use auto-attach carefully. It can conflict with SSH key-based automation on some systems.
Extend tmux with Tmux Plugin Manager (TPM). The tmux-resurrect plugin preserves sessions even across system reboots.
Tmux and Screen are essential tools for remote server management. When running long processes, build tasks, or continuous monitoring commands on REXE servers, these tools ensure your work is safe even if the SSH connection drops. Screen is a simpler starting point for beginners, but Tmux's flexibility and features make it the better long-term choice.
No. Tmux sessions run on the server side and are independent of your SSH connection. After reconnecting, use 'tmux attach' or 'tmux attach -t session-name' to resume exactly where you left off.
Tmux is recommended for new setups: it's actively developed, offers better mouse support and configuration options. Screen is useful for quick access on older systems where it comes pre-installed.
Add 'unbind C-b' and 'set-option -g prefix C-a' to ~/.tmux.conf. This changes the prefix to Ctrl+a, the same as Screen. Run 'tmux source-file ~/.tmux.conf' to apply the change.
Use the tmux-resurrect or tmux-continuum plugins. These save session state and restore it after a system restart. They can be easily installed with Tmux Plugin Manager (TPM).
Yes. Multiple users can attach to the same session with 'tmux attach -t session-name'. This is very useful for pair programming and collaborative troubleshooting. All participants see and can control the same screen.
Step-by-step SSH connection guide for Linux VDS: PuTTY, Terminal, key-based authentication, Path Panel firewall rules, and security best practices.
Complete guide to connecting to Windows Server VDS via Remote Desktop (RDP): setup steps, NLA security, Path Panel firewall rule, and troubleshooting tips.
Step-by-step guide to changing your VDS server OS via REXE panel: backup tips, supported Linux distributions and Windows Server versions explained.