
مدقق قائم على القواعد لملفات تكوين عميل OpenSSH يكتشف الـhosts المكررة، ملفات الهوية المفقودة، الخوارزميات الضعيفة، مشاكل ترتيب wildcard، والإعدادات الخطرة مع إخراج JSON ورموز خروج مناسبة لـ CI.
افحص ملف ~/.ssh/config بحثًا عن الأخطاء الشائعة.
يتحقق من وجود كتل مضيفة مكررة، ملفات هوية مفقودة، مشاكل ترتيب أحرف البدل، خوارزميات ضعيفة، توجيهات مكررة، والمزيد. يدعم توجيهات Include مع اكتشاف الدورات.
https://github.com/user-attachments/assets/4d995679-baed-4f20-9ba8-8f3ec94c64fd
curl -fsSL https://raw.githubusercontent.com/Noah4ever/sshconfig-lint/main/install.sh | bash
اضبط VERSION=v0.1.0 أو INSTALL_DIR=~/.local/bin لتجاوز القيم الافتراضية.
brew tap Noah4ever/tap
brew install sshconfig-lint
اختياري: استخدم untap Noah4ever/tap لإزالة المستودع والحفاظ على قائمة المستودعات نظيفة
cargo install sshconfig-lint
sshconfig-lint-bin - باينات مُجمَّعة مسبقاً
yay -S sshconfig-lint-bin
paru -S sshconfig-lint-bin
احصل على بايناري من صفحة الإصدارات.
# lint the default ~/.ssh/config
sshconfig-lint
# lint a specific file
sshconfig-lint --config /path/to/config
# json output
sshconfig-lint --format json
# treat warnings as errors (useful in CI)
sshconfig-lint --strict
# skip Include resolution
sshconfig-lint --no-includes
line 4: [warning] WILDCARD_ORDER (wildcard-host-order) Host 'github.com' appears after 'Host *' (line 1); it will never match because Host * already matched (hint: move Host * to the end of the file)
line 7: [warning] DUP_HOST (duplicate-host) duplicate Host block 'github.com' (first seen at line 4) (hint: remove one of the duplicate Host blocks)
line 3: [error] MISSING_IDENTITY (identity-file-exists) IdentityFile not found: ~/.ssh/id_missing (hint: check the path or remove the directive)
يتم فرز المخرجات حسب الملف ورقم السطر لضمان الثبات عبر عمليات التشغيل (مستقرة لاختلافات CI واللقطات).
الأخطاء باللون الأحمر، والتحذيرات باللون الأصفر، والمعلومات باللون السماوي. يتم تعطيل الألوان تلقائيًا إذا لم يكن stdout طرفية أو إذا تم تعيين NO_COLOR.
| Code | المعنى |
|---|---|
| 0 | نظيف، لم يتم العثور على أخطاء |
| 1 | يوجد على الأقل خطأ واحد (أو تحذير مع --strict) |
| 2 | ملف التهيئة غير موجود |
كل اكتشاف له رمز ثابت يمكنك البحث عنه أو مطابقته في النصوص البرمجية.
تتضمن الاكتشافات تلميحًا عند الإمكان، مثل "انقل Host * إلى نهاية الملف".
Host github.com gitlab.com)Include conf.d/*.conf extra.conf)IdentityFile ~/.ssh/id # my key)ProxyCommand "ssh -W %h:%p bastion")cargo test # run all tests
cargo test --lib # unit tests only
cargo clippy # lint
cargo fmt --check # formatting
src/
main.rs CLI
lib.rs Public API (lint_file, lint_str)
model.rs AST types
lexer.rs Tokenizer
parser.rs Builds config AST from tokens
resolve.rs Include expansion + cycle detection
report.rs Text and JSON formatters
rules/
mod.rs Rule trait and runner
basic.rs Built-in rules
tests/
fixtures/ Sample config files
cli.rs CLI integration tests
integration.rs Fixture-based tests
Rule في src/rules/basic.rsrun_all() في src/rules/mod.rsانظر CONTRIBUTING.md للمزيد من التفاصيل.
MIT
| Code | Rule | Severity | الوصف |
|---|
DUP_HOST | duplicate-host | تحذير | كتلتا Host بنفس النمط |
MISSING_IDENTITY | identity-file-exists | خطأ | مسار IdentityFile غير موجود |
WILDCARD_ORDER | wildcard-host-order | تحذير | يظهر Host * قبل أنماط محددة |
WEAK_ALGO | deprecated-weak-algorithms | تحذير | خوارزمية ضعيفة أو مهملة (3des-cbc, arcfour, hmac-md5, ssh-dss, إلخ) |
DUP_DIRECTIVE | duplicate-directives | تحذير | توجيه مكرر في نفس النطاق (القيمة الأولى فقط هي المؤثرة) |
INSECURE_OPT | insecure-option | تحذير | إعداد خطير مثل StrictHostKeyChecking no أو ForwardAgent yes على Host * |
UNSAFE_CTRL_PATH | unsafe-control-path | تحذير | ControlPath يفتقد %h، %p، %r (أو %C) — قد تشارك الاتصالات مقبسًا |
INCLUDE_CYCLE | include-cycle | خطأ | سلسلة Include دائرية |
INCLUDE_READ | include-read | خطأ | لا يمكن قراءة الملف المضمن |
INCLUDE_GLOB | include-glob | خطأ | نمط glob غير صالح في Include |
INCLUDE_NO_MATCH | include-no-match | معلومات | نمط Include لم يطابق أي ملفات |