C.W.K.
Stream
Lesson 04 of 12 · published

Wildcard Host

~15 min · wildcards, host-pattern, global-defaults

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

여러 host 에 설정 공유

Host 패턴의 wildcard 가 여러 host 에 한 번에 설정 적용. * 어떤 문자열이든 매치. ? 단일 문자 매치. 공백으로 패턴 여러 개 나열 가능.

매칭 작동 방식

SSH 가 ~/.ssh/config 위에서 아래로 읽음. 각 설정마다 first matching Host block 이 이김. 그래서 specific 이 general 위, catch-all Host * 가 맨 아래.

Host * 가 글로벌 디폴트 — override 안 한 모든 host 가 상속하는 설정.

Match vs Host

Host 외에 OpenSSH 가 Match block 도 지원 — user, originalhost, exec 결과 등에 의한 조건부 매칭. 고급 셋업에 유용, 개인 fleet 엔 과함. 95% 시간 Host 패턴 써.

Code

Wildcard 동작·ssh-config
# Specific host (highest priority)
Host office
    HostName 192.168.1.100
    User you_username

# Pattern match — all Tailscale hostnames
Host ts-*
    User you_username
    # No HostName here — relies on the alias resolving via DNS or another rule

# Pattern match — internal company hosts
Host *.internal.example.com
    User admin
    ProxyJump bastion

# Multiple patterns
Host dev1 dev2 dev3
    User you_username
    IdentityFile ~/.ssh/id_ed25519_dev

# Global catchall — MUST be last
Host *
    AddKeysToAgent yes
    UseKeychain yes
    IdentityFile ~/.ssh/id_ed25519
    ServerAliveInterval 60
    ServerAliveCountMax 3

External links

Exercise

현재 ~/.ssh/config 봐. Host * block 있어? 맨 아래야? 아니면 옮겨. 그다음 감사 — 여러 host 에 중복된 specific block 의 directive 어느 거? 그것들을 Host * 로 승격해서 각 specific block 이 minimal 유지하게. ssh -G one-host 로 설정 여전히 정확히 해석되는지 테스트.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.