# SSH Configuration **SSH configuration files** control connection defaults and options. The main file is `~/.ssh/config`, which lets you define host aliases, authentication options, and forwarding rules without typing them on every command. Basic syntax: ``` Host work HostName work.example.com User alice Port 2222 IdentityFile ~/.ssh/id_ed25519 Host * AddKeysToAgent yes StrictHostKeyChecking accept-new ``` Then connect with `ssh work` instead of `ssh -p 2222 alice@work.example.com`. Host patterns: - `Host work` — matches exactly "work" - `Host *.example.com` — matches all subdomains - `Host *` — matches all hosts (set defaults here) Common options: ``` HostName actual hostname or IP User username on remote Port SSH port (default 22) IdentityFile path to private key ProxyJump jump host (see ssh-jump-hosts) AddKeysToAgent add keys to SSH agent (yes/no) StrictHostKeyChecking ask/accept-new/no (host key verification) ServerAliveInterval idle timeout in seconds Compression enable compression (yes/no) ForwardAgent forward SSH agent to remote (yes/no) LocalForward local port forwarding RemoteForward remote port forwarding ``` SSH reads config top-to-bottom and uses the first matching value. More specific hosts should appear before `Host *`. View effective config for a host: `ssh -G work` (shows merged settings). Check syntax: `ssh -G hostname` (errors show invalid config).