Files
mtm-ssh-menu/README.md
T
matmoul 69131534fe feat: support jump host ports in SSH menu
Allow jump host definitions to include an explicit port in the form user@host:port.
Default to port 22 when no port is provided and update the sample config and docs accordingly.
2026-06-02 20:26:25 +02:00

111 lines
2.3 KiB
Markdown

# mtm-ssh-menu
A Bash SSH target picker built around `fzf` and YAML configuration.
## What it does
- Lists SSH targets from grouped YAML files
- Supports global defaults for user, port, and jump hosts
- Supports per-host overrides
- Can also browse entries from `~/.ssh/known_hosts`
- Launches `ssh` directly from the selected entry
## Requirements
- `ssh`
- `fzf`
- `jq`
- `yq`
## Usage
```bash
./mtm-ssh-menu [--config-dir DIR] [-k [user]]
```
Options:
- `-h`, `--help`: show help
- `--config-dir DIR`: use a custom configuration directory
- `-k`, `--known-hosts [user]`: include hosts from `~/.ssh/known_hosts`
By default, the script reads configuration from:
- `~/.config/mtm-ssh-menu/global.yaml`
- `~/.config/mtm-ssh-menu/hosts/*.yaml`
## Configuration format
### `global.yaml`
```yaml
ssh:
default_user: root
default_port: 22
default_options: ""
jump_hosts:
office: "user@192.168.10.11"
office-alt: "user@192.168.10.11:2222"
```
### `hosts/dev.yaml`
```yaml
group: dev
servers:
- name: api-1
aliases:
- api
- backend
host: 192.168.10.11
user: dev
port: 2222
- name: web-1
aliases:
- frontend
- ui
host: 192.168.10.12
user: dev
port: 22
```
### `hosts/prod.yaml`
```yaml
group: prod
servers:
- name: web-1
aliases:
- frontend
- web
host: web-1.prod.internal
jump_host: office
```
Each host entry can define:
- `name`
- `aliases`
- `host`
- `user`
- `port`
- `jump_host`
## Sample configuration
A complete sample configuration is available in `sample-config/`.
## Notes
- `jump_host` values are resolved by name from `global.yaml`.
- Jump hosts support `user@host` and `user@host:port`; if the port is omitted, `22` is used.
- 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.
- 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`).
- The script name shown in usage is `sshm`, while the repository file is `mtm-ssh-menu`.