SSH Config Cheat Sheet

Client-side SSH configuration examples for aliases, defaults, patterns, includes, ProxyJump, multiplexing, and effective config inspection.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all
## Client Config Basics
Basic host alias
Host web-prod
  HostName web01.example.com
  User deploy
  Port 22
  IdentityFile ~/.ssh/id_ed25519

# Create a short alias in ~/.ssh/config.

Global defaults
Host *
  ServerAliveInterval 30
  AddKeysToAgent yes
  IdentitiesOnly yes

# Set defaults that apply to all hosts.

Pattern-based host block
Host *.corp.internal
  User ops
  IdentityFile ~/.ssh/id_corp

# Match groups of hosts with wildcard patterns.

Canonicalize hostnames
Host *
  CanonicalizeHostname yes
  CanonicalDomains example.com corp.internal

# Resolve short names into FQDNs automatically.

Include extra config files
Include ~/.ssh/conf.d/*.conf

# Split config into multiple files.

Inspect merged config
ssh -G web-prod

# Show the effective configuration for a host.

## Client Config Advanced
ProxyJump in config
Host private-*
  ProxyJump bastion.example.com

# Configure a jump host once for repeated use.

Multiplexing in config
Host *
  ControlMaster auto
  ControlPath ~/.ssh/cm-%r@%h:%p
  ControlPersist 10m

# Enable connection sharing globally or per host.

Agent forwarding in config
Host jumpbox
  ForwardAgent yes

# Enable agent forwarding for specific hosts only.

Local forward in config
Host db-tunnel
  HostName bastion.example.com
  LocalForward 5432 db.internal:5432

# Attach a local tunnel to a host alias.

Use a specific SSH agent socket
Host secure-host
  IdentityAgent ~/.ssh/agent-sock

# Point a host entry at a chosen agent socket.

LocalCommand in config
Host telemetry
  PermitLocalCommand yes
  LocalCommand echo connected to %h

# Run a local command after a successful connection.

Recommended next

No recommendations yet.