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

The Config File

~15 min · ssh-config, precedence, ini-format

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

~/.ssh/config — your terminal command center

The ~/.ssh/config file is where SSH stops being a verb and starts being a habit. Instead of typing long flag soup every time, you define named hosts with all their settings — port, user, key, ProxyJump, you name it — and reference them by alias. ssh office instead of ssh -p 2222 -i ~/.ssh/id_ed25519_office you_username@192.168.1.100.

How precedence works

SSH resolves settings in this order (first match wins for each setting):

  1. Command-line flags-p 2222 overrides everything below.
  2. ~/.ssh/config — your personal client config.
  3. /etc/ssh/ssh_config — system-wide defaults.
  4. OpenSSH built-in defaults.

Within a config file, the first matching Host block wins for each setting. That's why specific entries go above general ones, and Host * goes at the bottom.

The format

It's an indented ini-style file. Comments start with #. Indentation is conventional, not required — SSH parses it just fine without indentation, but indented blocks are far easier to read.

Code

Create your config·bash
# Create the file if it doesn't exist
touch ~/.ssh/config
chmod 600 ~/.ssh/config

# Edit it
nano ~/.ssh/config

# Validate the syntax (without connecting)
ssh -G office | head
Minimal first config·ssh-config
# ~/.ssh/config

# Office Mac Studio on the LAN
Host office
    HostName 192.168.1.100
    User you_username

# Global defaults — last block in the file
Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_ed25519
    ServerAliveInterval 60

External links

Exercise

Create or open ~/.ssh/config. Add a single Host block for one machine you SSH into often. Test with ssh -G that-host to see all the resolved settings, then ssh that-host to confirm it connects without typing user/IP/port. This one habit will save you minutes every day for the rest of your terminal life.

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.