ce563186cb03e5eaa14838a47cc45e3baa117478
Replace the Bash implementation and jq/yq dependency chain with a Bun-based TypeScript script, add Bun/TypeScript project files, and update docs and sample config notes to match the new CLI and behavior.
mtm-ssh-menu
A Bun/TypeScript SSH target picker built around fzf and YAML configuration.
What it does
- Lists SSH targets from grouped YAML files
- Uses the
groupvalue 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 - Launches
sshdirectly from the selected entry
Requirements
bunsshfzf
Usage
./mtm-ssh-menu [--config-dir DIR] [-k [user]]
The usage shown by the script is sshm [--config-dir DIR] [-k [user]].
Options:
-h,--help: show help-c,--config-dir DIR: use a custom configuration directory-k,--known-hosts [user]: include hosts from~/.ssh/known_hostsand optionally set the user- When
-kis used without a user, the selected entry usesroot
By default, the script reads configuration from:
~/.config/mtm-ssh-menu/global.yaml~/.config/mtm-ssh-menu/hosts/*.yaml
Configuration format
global.yaml
ssh:
default_user: root
default_port: 22
default_options: ""
jump_hosts:
office: "user@192.168.10.11"
dev: "user@192.168.10.11:2222"
backup: "admin@10.0.0.5:2200"
hosts/01_prod.yaml
group: prod
servers:
- name: web-1
aliases:
- frontend
- web
host: web-1.prod.internal
jump_host: office
- name: db-1
aliases:
- database
- sql
host: 10.0.0.20
jump_host: office
hosts/02_staging.yaml
group: staging
servers:
- name: app-1
aliases:
- app
- application
host: staging-app.example.com
user: ubuntu
port: 22
ssh_options: ""
- name: worker-1
aliases:
- worker
host: 10.20.0.15
user: ubuntu
port: 22
hosts/03_dev.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
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 uses numbered file names: 01_prod.yaml, 02_staging.yaml, and 03_dev.yaml.
Each host entry can define:
namealiaseshostuserportjump_host
Sample configuration
A complete sample configuration is available in sample-config/.
Notes
jump_hostvalues are resolved by name fromglobal.yaml.- Jump hosts support
user@hostanduser@host:port; if the port is omitted,22is used. - If a host does not define a user or port, global defaults are used.
default_optionsis consumed for hosts that do not define their ownoptions, and is appended as raw SSH options.ssh_optionsappears in the sample config but is not used by the current script; onlyoptionsis read.- Sample host examples are stored as
sample-config/hosts/01_prod.yaml,02_staging.yaml, and03_dev.yaml. - The
groupkey is required for each host config file; the file name is only an internal storage detail. - When
-kis used, entries fromknown_hostsare shown with the selected user orrootby default. - Known-host entries always use port
22. known_hostsentries use port22.- The script is implemented in Bun and launches
fzfplussshfrom a parsed YAML configuration. - The current implementation builds the final SSH command as a string and executes it through Bun.
- The script name shown in usage is
sshm, while the repository file ismtm-ssh-menu.
Description
Languages
TypeScript
82.1%
Shell
17.9%