Skip to main content

Configuration

SSH Shield is configured via a YAML file. The path is passed as a command-line argument at startup. String values support ${ENV_VAR} substitution and !file <path> directives that load the value from a file on disk.

Top-level fields

FieldDescription
natsNATS connection and subject configuration. See NATS.
blockerDetection policy, ban schedule, and memory management. See Blocker.
stateStorePer-IP rate-limit state store. See State store.
pluginsList of firewall plugins used to enforce blocks. See Plugins.

NATS

SSH Shield subscribes to the failure event stream published by the SSH Proxy.

FieldDefaultDescription
hostrequiredNATS server hostname. Supports ${ENV_VAR} substitution.
port4222NATS server port.
userNATS username.
passwordNATS password. Use !file <path> to load from a mounted secret.
sshFailures.subjectssh.failuresNATS subject SSH Shield subscribes to for failure events. Must match the subject configured on the SSH Proxy.

Blocker

The blocker block controls the sliding-window detection policy, the ban schedule, and memory management. See IP Blocking for a full description of how these settings interact at runtime.

Detection

FieldDefaultDescription
windowrequiredSliding time window for counting failures per IP. Accepts Go duration strings (e.g. 5m, 1h). Failures older than this are discarded.
thresholdrequiredNumber of failures within window that triggers a ban.
decreasingThresholdfalseWhen true, each ban reduces the threshold for that IP by one (minimum one). Repeat offenders are banned faster with each cycle. See Strike-based ban schedule.
banSchedulerequiredList of ban durations indexed by strike count. The first entry applies on first ban, the last entry is reused once all slots are exhausted. Example: [1m, 5m, 15m, 1h, 6h, 24h, 72h].
whitelistList of CIDR ranges that are never banned. Failure events from whitelisted IPs are discarded before the hit counter is consulted. See Whitelist.

Memory management

FieldDefaultDescription
gcIntervalHow often the garbage collection routine runs. GC is disabled when omitted or zero.
idleCleanupRemoves in-memory state for IPs not seen within this duration. Applied each GC cycle.
maxIPState0Hard cap on the number of IP states held in memory. When the cap is exceeded, the oldest entries by last-seen time are evicted. 0 means unlimited.

State store

Controls where per-IP rate-limit state is held. See State store for a description of the two modes.

FieldDefaultDescription
typememoryState store type. memory keeps state in-process; nats-kv stores state in a NATS JetStream KV bucket shared across all instances.
bucketJetStream KV bucket name. Required when type is nats-kv. Created automatically if it does not exist.

Plugins

Each entry in the plugins list activates a firewall plugin. All listed plugins receive every block decision. SSH Shield currently supports the nfgate plugin type; cloud provider plugins are on the roadmap. See Firewall plugins.

FieldDefaultDescription
typerequiredPlugin type. Currently nfgate is the only supported value.
configFilerequiredPath to the plugin-specific configuration file. Relative paths are resolved from the main config file directory.

nfgate plugin configuration

The nfgate plugin configuration file is referenced by configFile in the plugins list.

FieldDefaultDescription
addressrequiredAddress of the nfgate gRPC endpoint (e.g. localhost:9090).
tlsfalseEnable TLS on the gRPC connection.
certFilePath to the CA certificate file used to verify the nfgate server when TLS is enabled.
dialTimeoutMaximum time to wait when dialing the gRPC endpoint. Accepts Go duration strings (e.g. 5s).
authKeyShared secret sent as Authorization: Bearer <key> in every gRPC call. Must match the authKey configured on the nfgate server.