Host <pattern> [<pattern2> ...]Opens a config block that applies to hosts matching the pattern. Wildcards: * matches any sequence, ? matches any single character. For each directive, the first matching Host block wins — later blocks can add but not override already-set values.
⚠ Common pitfall: Host * (global defaults) must come LAST in the file. SSH processes blocks top-to-bottom and stops at the first match per directive, so a Host * at the top will shadow every specific block below it.
# ~/.ssh/config — specific host alias Host dev HostName dev.example.com User alice Port 2222 IdentityFile ~/.ssh/id_ed25519 # Connect: ssh dev
# Wildcard: any host in *.staging.company.com Host *.staging.company.com User deployer IdentityFile ~/.ssh/staging_ed25519
# Global defaults — must be LAST Host * ServerAliveInterval 60 ServerAliveCountMax 3 AddKeysToAgent yes