ssh-manager-kit
v1.0.2
Published
CLI tool for managing SSH hosts in ~/.ssh/config
Readme
ssh-manager-kit
CLI tool for managing SSH hosts in ~/.ssh/config.
Add, list, search, update, and delete hosts without hand-editing your SSH config. Supports a default key directory, host alias prefixes, and automatically enforces chmod 400 on private keys.
Install
npm install -g ssh-manager-kitUsage
# List all hosts
ssh-mgr list
# Search hosts by name, hostname, or user
ssh-mgr search prod
# Show details of a host
ssh-mgr show my-server
# Add a host (flags mode — no prompts)
ssh-mgr add my-server --hostname 192.168.1.10 --user deploy --port 22 --key deploy_key
# Add a host (interactive — prompts for everything)
ssh-mgr add
# Add a host and skip confirmation
ssh-mgr add my-server --hostname 1.2.3.4 --user root -y
# Update a host
ssh-mgr update my-server --user root --port 2222
# Delete a host (with confirmation)
ssh-mgr delete my-server
# Delete without confirmation
ssh-mgr delete my-server --forceCommands
| Command | Description |
|---|---|
| list | Show all SSH hosts in a table |
| search <query> | Search hosts by alias, hostname, or user |
| show <host> | Show details of a host |
| add [host] | Add a new SSH host |
| update <host> | Update an existing SSH host |
| delete <host> | Delete an SSH host |
| config show | Display current configuration |
| config set-key-path <path> | Set default private key directory |
| config set-prefix <prefix> | Set host alias prefix |
Add / Update Options
| Flag | Description |
|---|---|
| --hostname <hostname> | HostName (IP or domain) |
| --user <user> | User |
| --port <port> | Port number |
| --key <key> | Private key filename or full path |
| -y, --yes | Skip confirmation prompt |
Configuration
Config is stored at ~/.config/.ssh-manager-kit.json.
# Show current configuration
ssh-mgr config showDefault Key Path
Set a default directory for private keys so you can reference them by filename:
ssh-mgr config set-key-path ~/.sshAfter this, --key deploy_key resolves to ~/.ssh/deploy_key. Keys containing / are treated as full paths and used as-is.
Host Prefix
Set a prefix that is automatically prepended to host aliases during interactive add:
ssh-mgr config set-prefix prod-When a prefix is set, ssh-mgr add (interactive mode) prompts:
Host alias (prefix: prod-): web-01The resulting alias is prod-web-01. The prefix is only applied in interactive mode — passing a [host] argument on the command line uses the alias verbatim.
Clear the prefix:
ssh-mgr config set-prefix ""Hybrid Input
Commands accept flags for scripting. When required fields are missing, the tool prompts interactively.
# Full flags — no prompts
ssh-mgr add my-server --hostname 1.2.3.4 --user root --port 22 --key mykey
# Only host + hostname — no prompts for optional fields
ssh-mgr add my-server --hostname 1.2.3.4
# No arguments — fully interactive
ssh-mgr addSafety
- Auto-backup: Creates a timestamped backup of
~/.ssh/configbefore every write (e.g.,config.bak.2026-03-30T14-30-00). - Round-trip validation: After writing, the tool re-parses the output and compares against the original data. If validation fails, the backup is automatically restored.
- Preserves formatting: Comments, blank lines, and unrecognized SSH options (ForwardAgent, ProxyJump, etc.) are preserved through all operations.
- Key permissions: When adding or updating a host with an IdentityFile, the tool checks the key file and runs
chmod 400if permissions are too open. - Key existence warning: When adding or updating a host, warns if the resolved IdentityFile path does not exist on disk. The entry is still saved.
Development
# Install dependencies
npm install
# Run in dev mode
npm run dev -- list
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Build
npm run build
# Build and link globally for local testing
npm run local
# Unlink
npm run local:unlinkLicense
ISC
