C.W.K.
Stream
Lesson 03 of 12 · published

Full Config Block

~15 min · ssh-config, directives, compression, keepalive

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

Anatomy of a complete Host block

Every directive you'll commonly use, in one place. Most blocks need only a subset, but knowing what's available prevents reinventing wheels.

The directives that matter most day-to-day

DirectivePurpose
HostNameActual address (IP or FQDN)
UserRemote username
PortSSH port (default 22)
IdentityFilePath to the private key
IdentitiesOnlyDon't try every key in agent — only IdentityFile
ForwardAgentForward your agent (default: no, keep it that way)
ProxyJumpHop through this host first (next lessons)
CompressionCompress on slow links (off on fast LAN)
ServerAliveIntervalKeepalive every N seconds
ServerAliveCountMaxDisconnect after N missed keepalives
AddKeysToAgentAuto-add used keys to agent
UseKeychainmacOS — pull passphrase from Keychain
ControlMaster / Path / PersistMultiplex connections (later lesson)

Indentation is convention, not rule

SSH parses the file fine without indentation, but indented blocks are dramatically more readable when you have 20 hosts. Pick a style and stick with it.

Code

A fully-loaded block·ssh-config
Host office
    HostName 192.168.1.100      # IP or FQDN
    User you_username                  # remote username
    Port 22                      # SSH port
    IdentityFile ~/.ssh/id_ed25519_office
    IdentitiesOnly yes           # only try this key
    ForwardAgent no              # keep agent here, not forwarded
    Compression no               # fast LAN, no compression
    ServerAliveInterval 60       # keepalive every 60s
    ServerAliveCountMax 3        # disconnect after 3 misses (3 min total)
    AddKeysToAgent yes
    UseKeychain yes              # macOS only

External links

Exercise

Pick your most-used host alias. Open the block and verify it has at least: HostName, User, IdentityFile, ServerAliveInterval, AddKeysToAgent. Add what's missing. Then run ssh -G that-host and skim the resolved settings — you'll see all the inherited defaults from Host * plus your block's overrides.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.