Skip to content

Host Patterns

Eric Kochen edited this page Apr 2, 2026 · 2 revisions

What are host patterns?

SSH configs support wildcard Host blocks that apply settings to groups of hosts. For example:

Host *.example.com
    User admin
    IdentityFile ~/.ssh/id_example

Host 10.30.0.*
    User debian
    ProxyJump bastion

Host *
    ServerAliveInterval 60

These pattern blocks use SSH glob syntax to match against the alias typed on the command line. purple displays them in a dedicated Patterns group at the bottom of the host list, separate from concrete hosts.

Pattern syntax

Syntax Meaning Example
* Any sequence of characters *.example.com matches web.example.com
? Any single character server-? matches server-1 but not server-10
[abc] Any character in the set server-[abc] matches server-a
[a-z] Any character in the range server-[0-9] matches server-5
[!abc] or [^abc] Any character not in the set server-[!abc] matches server-d
!pattern Negation (exclude matches) *.example.com !internal.example.com
Space-separated Multiple patterns prod staging matches either

Negation patterns only exclude. A Host line with only negation patterns (like !prod !staging) never matches anything on its own.

Managing patterns in the TUI

Key Action
A Add a new pattern
e Edit selected pattern
d Delete selected pattern
c Clone pattern

When adding a pattern, the form requires a wildcard character or multiple space-separated hosts. Hostname is optional for patterns (unlike concrete hosts).

Patterns from included files (via Include directives) are displayed but cannot be edited. Edit them in the source file.

Detail panel

Press v to open the detail panel. When a pattern is selected, the detail panel shows:

  • Directives in the pattern block
  • Tags assigned to the pattern
  • Matches listing all concrete hosts whose alias or hostname matches the pattern

When a concrete host is selected, the detail panel shows a PATTERN MATCH section at the bottom. This lists all pattern blocks that match the host, with their directives. This helps you understand which settings are inherited from wildcard blocks.

Search and filtering

Patterns are included in search results. Type / and search by pattern name. Tag filtering works too:

  • tag:internal fuzzy-matches pattern tags
  • tag=internal exact-matches pattern tags

The search counter shows combined host and pattern results.

Tags

Patterns support user tags, stored the same way as host tags:

Host 10.30.0.*
    User debian
    # purple:tags internal,vpn

Pattern tags appear in the tag picker and contribute to tag counts.

How patterns work in SSH

SSH processes Host blocks in config order (first match wins for each directive). A wildcard block like Host * applies to every connection, but only for directives not already set by an earlier, more specific block.

purple matches patterns against the alias (the name typed on the command line), not the resolved hostname. This follows OpenSSH behavior. The detail panel additionally shows hostname matches for convenience.

Clone this wiki locally