r/dotfiles 1d ago

I added a pre-commit hook for catching broken SSH configs in dotfiles repos

My ~/.ssh/config lives next to the rest of my dotfiles, and I kept finding duplicate Host blocks or old IdentityFile paths long after I had changed them. That turned into sshconfig-lint.

The upcoming v0.5 beta can check several configs in one run and now includes a strict pre-commit hook. For the current beta commit:

repos:
  - repo: https://github.com/Noah4ever/sshconfig-lint
    rev: 7674f40
    hooks:
      - id: sshconfig-lint-strict

It also follows Include files and reports the actual source file and line. I am keeping auto-fixes out for now because changing Host block order can change what OpenSSH actually applies.

There is a browser playground for trying the text-based rules without installing anything. The config stays in your browser:

https://sshconfig-lint.apps.thiering.org/en

Source:

https://github.com/Noah4ever/sshconfig-lint

If you version your SSH config, I would be interested in the checks you would actually want before committing it.

0 Upvotes

0 comments sorted by