feat: require explicit group names in host configs

This commit is contained in:
2026-06-02 20:36:51 +02:00
parent 69131534fe
commit 87945adae3
6 changed files with 26 additions and 16 deletions
+12 -4
View File
@@ -5,6 +5,8 @@ A Bash SSH target picker built around `fzf` and YAML configuration.
## What it does
- Lists SSH targets from grouped YAML files
- Uses the `group` value from each YAML file as the displayed group name
- Allows the YAML file name to differ from the group name
- Supports global defaults for user, port, and jump hosts
- Supports per-host overrides
- Can also browse entries from `~/.ssh/known_hosts`
@@ -49,10 +51,10 @@ ssh:
```
### `hosts/dev.yaml`
### `hosts/01_prod.yaml`
```yaml
group: dev
group: prod
servers:
- name: api-1
aliases:
@@ -71,10 +73,10 @@ servers:
port: 22
```
### `hosts/prod.yaml`
### `hosts/03_dev.yaml`
```yaml
group: prod
group: dev
servers:
- name: web-1
aliases:
@@ -84,6 +86,10 @@ servers:
jump_host: office
```
The file name does not need to match the `group` value. The script reads the `group` from the YAML content and uses the file path internally to load the selected host.
The sample configuration now uses numbered file names such as `01_prod.yaml`, `02_staging.yaml`, and `03_dev.yaml`.
Each host entry can define:
- `name`
@@ -104,6 +110,8 @@ A complete sample configuration is available in `sample-config/`.
- If a host does not define a user or port, global defaults are used.
- `default_options` is present in the config but not consumed by the current script.
- The sample config includes `ssh_options` in one file, but the current script does not consume it yet.
- Sample host examples are stored as `sample-config/hosts/01_prod.yaml`, `02_staging.yaml`, and `03_dev.yaml`.
- The `group` key is required for each host config file; the file name is only an internal storage detail.
- When `-k` is used, entries from `known_hosts` are shown with the selected user or `root` by default.
- `known_hosts` entries use port `22`.
- The script uses strict Bash mode (`set -euo pipefail`).