AI Tools Free

SSH Config Validator (Syntax, First-Match Precedence & Security Audit)

Audit OpenSSH `~/.ssh/config` files locally in your browser: verify directive syntax, catch **first-match-wins (`Host *`) shadowing bugs**, check `ProxyJump` references, and flag `ForwardAgent` / `StrictHostKeyChecking` security hazards.

Free to useNo sign-upRuns in your browser
Enter your details

Enter the inputs, then select Validate SSH Config.

Paste your ~/.ssh/config text. Audited 100% locally in your browser.

Strict mode warns when 'Host *' appears before specific Host blocks or when ForwardAgent / StrictHostKeyChecking are unsafe.

Your result
Enter your details

Result will appear here

How OpenSSH First-Match-Wins Evaluation Works

The single most common `~/.ssh/config` bug is treating `Host *` at the top of the file as "default values to be overridden later."

EffectiveValue(HostAlias, DirectiveKey) = FirstMatchingHostBlock(TopToBottom).get(DirectiveKey)

Because OpenSSH stops updating a directive as soon as it sees the first matching Host block that defines that directive, specific Host blocks must come first and 'Host *' must come last.

SSH Config Validator (Syntax, First-Match Precedence & Security Audit) workflow overview
Workflow overview for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

OpenSSH ~/.ssh/config Precedence & Security Audit Rules

Key syntactic, ordering, and security checks performed by the validator on your `~/.ssh/config` file.

Check CategoryMisconfiguration PatternActual OpenSSH Runtime EffectValidator Verdict & Fix
**First-Match-Wins Ordering**`Host *` placed **above** `Host prod-db`Global defaults in `Host *` silently shadow `User` / `Port` in later blocks**WARN (`Shadowed Host`)** — Move `Host *` to the bottom of the file
**Agent Forwarding Exposure**`ForwardAgent yes` on wildcard or bastion hostRemote root user can hijack your local `ssh-agent` socket**WARN (`Security Risk`)** — Replace with `ProxyJump bastion`
**MITM Host Verification**`StrictHostKeyChecking no`Accepts forged or changed host keys without warning**WARN (`Security Risk`)** — Use `accept-new` or `yes`
**Default 3-Block Sample**`bastion` (`:2222`), `prod-db` (`ProxyJump bastion`), `Host *` lastClean first-match order, valid ports, `IdentitiesOnly yes`**`VALID (3 Host blocks, 0 errors, 0 warnings)`**

How to Validate Your ~/.ssh/config File

Audit your SSH client configuration in three steps.

Paste your ~/.ssh/config contents

Paste the contents of `~/.ssh/config` or `/etc/ssh/ssh_config` into the editor.

SSH Config Validator (Syntax, First-Match Precedence & Security Audit) step 1: Paste your ~/.ssh/config contents
Step 1 workflow overview for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

Select Strict Security & Precedence Audit or Syntax Only

Keep 'Strict Security & Precedence Audit' enabled to catch both syntax errors and wildcard shadowing / security warnings.

SSH Config Validator (Syntax, First-Match Precedence & Security Audit) step 2: Select Strict Security & Precedence Audit or Syntax Only
Step 2 workflow overview for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

Review the per-block audit and effective resolution summary

Click Validate SSH Config to see all parsed Host blocks, line-level errors/warnings, and ProxyJump chain checks.

SSH Config Validator (Syntax, First-Match Precedence & Security Audit) step 3: Review the per-block audit and effective resolution summary
Step 3 workflow overview for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

Worked SSH Config Validation Examples

Compare a properly ordered bastion + jump-host config against common pitfalls.

Default Bastion + ProxyJump + Bottom Host * Config

The default 3-block config defines 'Host bastion' (Port 2222), 'Host prod-db' (ProxyJump bastion), and 'Host *' at the very bottom—passing with 3 Host blocks, 12 directives, 0 errors, and 0 warnings.

SSH Config Validator (Syntax, First-Match Precedence & Security Audit) example 1: Default Bastion + ProxyJump + Bottom Host * Config
Worked example 1 for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

Detecting Top-of-File 'Host *' Shadowing

If 'Host *' is placed at line 1 above 'Host bastion', Strict Mode flags a precedence warning explaining that directives inside 'Host *' will override later specific blocks.

SSH Config Validator (Syntax, First-Match Precedence & Security Audit) example 2: Detecting Top-of-File 'Host *' Shadowing
Worked example 2 for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

Catching Invalid Ports & Unknown Directives

Entering 'Port 70000' or a misspelled directive like 'HostNmae' immediately fails validation with the exact line number.

SSH Config Validator (Syntax, First-Match Precedence & Security Audit) example 3: Catching Invalid Ports & Unknown Directives
Worked example 3 for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

How to Read the SSH Config Audit Report

The validator separates hard syntax errors from precedence and security warnings.

The primary result badge displays `VALID` or `INVALID` along with the count of Host/Match blocks, total directives, errors, and warnings.

The detailed audit lists every parsed Host block (`HostName`, `User`, `Port`, `ProxyJump`) followed by line-referenced diagnostics.

How to interpret SSH Config Validator (Syntax, First-Match Precedence & Security Audit) results
Result interpretation guide for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

Local Browser Execution & Scope Limits

Understand what static config validation checks vs. live network probing.

This tool performs static syntactic, precedence, and security analysis 100% inside your browser; it does not open TCP sockets or test live SSH reachability.

To verify how your local OpenSSH binary resolves a specific alias on disk, you can also run `ssh -G <host-alias>` in your terminal.

Scope limits and assumptions for SSH Config Validator (Syntax, First-Match Precedence & Security Audit)
Assumptions and input boundaries for SSH Config Validator (Syntax, First-Match Precedence & Security Audit).

Frequently Asked Questions About ~/.ssh/config Validation

Answers about using SSH Config Validator (Syntax, First-Match Precedence & Security Audit) and understanding its results.

Why must 'Host *' be placed at the bottom of ~/.ssh/config instead of the top?

Contrary to CSS or many config formats where later declarations override earlier ones, OpenSSH's ssh_config(5) uses a strict FIRST-MATCH-WINS rule: for each parameter, the first obtained value is used. If you put 'Host *' with 'User ubuntu' at the top of ~/.ssh/config, every subsequent 'Host prod-db' block's 'User postgres' line will be silently ignored!

Why is 'ForwardAgent yes' in 'Host *' or untrusted hosts a critical security risk?

Enabling 'ForwardAgent yes' exposes a UNIX domain socket on the remote server that connects back to your local ssh-agent. Anyone with root access (or your UID) on that remote server can use your local SSH keys to authenticate to any other server you can access while your session is open. Always prefer 'ProxyJump' over 'ForwardAgent'.

What does 'IdentitiesOnly yes' prevent during SSH connection setup?

By default, ssh-agent offers every loaded key in memory before trying the specific 'IdentityFile' configured for a host. If you have 5+ keys loaded in ssh-agent, the remote sshd hits 'MaxAuthTries' (default 6) and disconnects with 'Too many authentication failures'. Setting 'IdentitiesOnly yes' restricts SSH to only the IdentityFile(s) explicitly declared for that host.

What is the difference between 'StrictHostKeyChecking no' and 'accept-new'?

Setting 'StrictHostKeyChecking no' disables man-in-the-middle (MITM) host key verification even when a known server's host key changes unexpectedly. OpenSSH 7.6+ introduced 'StrictHostKeyChecking accept-new', which automatically trusts brand-new hosts on first connection while still blocking connections if an existing host's key changes.

Try your own values

Choose another tool for your next calculation, conversion, or text task.

Validate SSH Config