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

Host entries, defaults, and matching.

Basic host alias

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

sshconfigANYsshconfigalias
sshconfig
Host web-prod
  HostName web01.example.com
  User deploy
  Port 22
  IdentityFile ~/.ssh/id_ed25519
Notes

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

Global defaults

Set defaults that apply to all hosts.

sshconfigANYsshconfigdefaults
sshconfig
Host *
  ServerAliveInterval 30
  AddKeysToAgent yes
  IdentitiesOnly yes
Notes

Set defaults that apply to all hosts.

Pattern-based host block

Match groups of hosts with wildcard patterns.

sshconfigANYsshconfigpatterns
sshconfig
Host *.corp.internal
  User ops
  IdentityFile ~/.ssh/id_corp
Notes

Match groups of hosts with wildcard patterns.

Canonicalize hostnames

Resolve short names into FQDNs automatically.

sshconfigANYsshconfighostname
sshconfig
Host *
  CanonicalizeHostname yes
  CanonicalDomains example.com corp.internal
Notes

Resolve short names into FQDNs automatically.

Include extra config files

Split config into multiple files.

sshconfigANYsshconfiginclude
sshconfig
Include ~/.ssh/conf.d/*.conf
Notes

Split config into multiple files.

Inspect merged config

Show the effective configuration for a host.

bashANYsshconfiginspect
bash
ssh -G web-prod
Notes

Show the effective configuration for a host.

Client Config Advanced

Jump hosts, multiplexing, agent forwarding, and local commands in config.

ProxyJump in config

Configure a jump host once for repeated use.

sshconfigANYsshconfigproxyjump
sshconfig
Host private-*
  ProxyJump bastion.example.com
Notes

Configure a jump host once for repeated use.

Multiplexing in config

Enable connection sharing globally or per host.

sshconfigANYsshconfigmultiplexing
sshconfig
Host *
  ControlMaster auto
  ControlPath ~/.ssh/cm-%r@%h:%p
  ControlPersist 10m
Notes

Enable connection sharing globally or per host.

Agent forwarding in config

Enable agent forwarding for specific hosts only.

sshconfigANYsshconfigagent-forwarding
sshconfig
Host jumpbox
  ForwardAgent yes
Notes

Enable agent forwarding for specific hosts only.

Local forward in config

Attach a local tunnel to a host alias.

sshconfigANYsshconfigforwarding
sshconfig
Host db-tunnel
  HostName bastion.example.com
  LocalForward 5432 db.internal:5432
Notes

Attach a local tunnel to a host alias.

Use a specific SSH agent socket

Point a host entry at a chosen agent socket.

sshconfigANYsshconfigagent
sshconfig
Host secure-host
  IdentityAgent ~/.ssh/agent-sock
Notes

Point a host entry at a chosen agent socket.

LocalCommand in config

Run a local command after a successful connection.

sshconfigANYsshconfiglocalcommand
sshconfig
Host telemetry
  PermitLocalCommand yes
  LocalCommand echo connected to %h
Notes

Run a local command after a successful connection.

Recommended next

No recommendations yet.