
OpenSSH 클라이언트 구성 파일을 위한 규칙 기반 린터로, 중복 호스트, 누락된 ID 파일, 취약한 알고리즘, 와일드카드 정렬 문제, 위험한 설정을 감지하며 JSON 출력 및 CI 친화적인 종료 코드를 제공합니다.
~/.ssh/config 파일을 일반적인 실수에 대해 린트합니다.
중복 호스트 블록, 누락된 ID 파일, 와일드카드 순서 문제, 취약한 알고리즘, 중복 지시문 등을 검사합니다. 사이클 감지 기능이 있는 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을 실행하여 tap을 제거하고 tap 목록을 깨끗하게 유지하세요.
cargo install sshconfig-lint
sshconfig-lint-bin - 미리 빌드된 바이너리
yay -S sshconfig-lint-bin
paru -S sshconfig-lint-bin
릴리즈 페이지에서 바이너리를 받으세요.
# 기본 ~/.ssh/config 린트
sshconfig-lint
# 특정 파일 린트
sshconfig-lint --config /path/to/config
# json 출력
sshconfig-lint --format json
# 경고를 오류로 처리 (CI에서 유용)
sshconfig-lint --strict
# Include 해석 생략
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 diff 및 스냅샷에 안정적입니다).
오류는 빨간색, 경고는 노란색, 정보는 청록색입니다. stdout이 터미널이 아니거나 NO_COLOR가 설정되면 색상이 자동으로 비활성화됩니다.
| 코드 | 의미 |
|---|---|
| 0 | 깨끗함, 오류 없음 |
| 1 | 최소 하나의 오류 수준 발견 (또는 --strict에서 경고) |
| 2 | 설정 파일을 찾을 수 없음 |
각 발견에는 스크립트에서 grep하거나 매칭할 수 있는 안정적인 코드가 있습니다.
발견에는 가능한 경우 힌트가 포함됩니다. 예: "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 # 모든 테스트 실행
cargo test --lib # 단위 테스트만
cargo clippy # 린트
cargo fmt --check # 포맷 검사
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
src/rules/basic.rs에서 Rule 트레이트를 구현하세요.src/rules/mod.rs의 run_all()에 등록하세요.자세한 내용은 CONTRIBUTING.md를 참조하세요.
MIT
| 코드 | 규칙 | 심각도 | 설명 |
|---|
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 on 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 | 오류 | 잘못된 Include glob 패턴 |
INCLUDE_NO_MATCH | include-no-match | 정보 | Include 패턴과 일치하는 파일 없음 |