I was today years old when I figured out how and why to use a "Match" line in my ssh config instead of "Host". I'm kind of low-key angry that every ssh guide tells people to use Host instead of Match now.

Quick summary: instead of just using

Host hostname.domain

you can use

Match user username host "hostname.domain"

If you have multiple user logins on the same box (say, you're using gitea), this will use the right key for the right login. With "Host", ssh will always just use the first key that matches the hostname, regardless of the User directive. Makes sense when you think about it, but non-obvious if you don't realize Match exists.

Follow

(welcome to toot number 1000 in my series of toots in which I write "today I learned X" and then immediately afterwards realize that I didn't explain what I learned in my original toot)

@phooky Also can use wildcards when using match. Really useful if you got a bunch of hosts like pi1.local to pi5.local that need the same configuration.

Sign in to participate in the conversation
Octodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!