sshmx is a lightweight Bash utility that helps you manage and launch SSH sessions inside tmux.
It integrates with your existing ~/.ssh/config or lets you add/remove sessions interactively, and provides handy tmux key bindings (Ctrl+b C-s for sessions, Ctrl+b C-g for groups) to quickly open SSH connections in popup windows.
- Interactive SSH session selector using fzf with multi-select and preview
- Automatic JSON session store (
~/.ssh/sessions.json) - Import from
~/.ssh/configor create sessions manually - tmux integration:
- New SSH sessions open in dedicated
tmuxwindows - Popup window shortcuts (
Ctrl+b C-sfor sessions,Ctrl+b C-gfor groups) to runsshmx
- New SSH sessions open in dedicated
- Jump host (ProxyJump) support
- Password and private key support (passwords are stored encrypted with GPG;
sshpassis used for authentication when needed) - Group support: Organize and connect to all sessions in a group at once
- Export/Import sessions for backups and sharing
- Optional colored output with chromaterm
- Host IP resolution using
getent(if available) - Self-installing script β just run once and it sets itself up
- Sync with
~/.ssh/configpreserving encrypted passwords and groups - Logging for debugging parsing issues
- Password migration tool: convert old plaintext passwords to GPG-encrypted format
- tmux
- fzf
- jq
- sshpass (optional, for password auth)
- chromaterm (optional, for colored output)
getent(optional, for hostname to IP resolution; usually available on Linux)
Clone the repository and run the script with the --install flag:
git clone https://github.com/yourusername/sshmx.git
cd sshmx
./sshmx --installThis will:
- Create a symlink to
~/.local/bin/sshmx - Add
Ctrl+b C-sandCtrl+b C-gbindings to your~/.tmux.conf(or create one if missing) - Add bash completion for command flags
- Add
~/.local/binto your PATH (via~/.bashrc)
Reload tmux:
tmux source-file ~/.tmux.confAnd source bashrc:
source ~/.bashrc| Command | Description |
|---|---|
sshmx |
Launch interactive session selector with fzf (multi-select, preview) |
sshmx --add / sshmx -a |
Add a new SSH session interactively |
sshmx --remove / sshmx -r |
Remove one or more sessions interactively (with backup) |
sshmx --install / sshmx -i |
Install script, create symlink, add tmux bindings, bash completion |
sshmx --sync / sshmx -s |
Sync ~/.ssh/sessions.json with ~/.ssh/config (preserves passwords/groups) |
sshmx --groups / sshmx -g |
Select and connect to all sessions in chosen group(s) |
sshmx --multiplex / sshmx -m |
Select active tmux windows (SSH sessions) and move them to a single synchronized window for multiplex commands |
sshmx --demultiplex / sshmx -d |
Restore panes from a multiplexed window back to separate windows |
sshmx --export / sshmx -e |
Export sessions.json to a backup file (prompts for filename) |
sshmx --import / sshmx -p |
Import sessions from a JSON file (overwrites current, backs up existing) |
sshmx --migrate-passwords |
Migrate old plaintext passwords in sessions.json to encrypted GPG format |
sshmx --help / sshmx -h |
Show this help message |
The script auto-generates a sessions.json file at ~/.ssh/sessions.json by parsing your ~/.ssh/config.
If no sessions are found, it creates a sample entry.
On first run without installation, it auto-installs itself.
sshmx- Prompts you with an
fzfselector of available sessions (multi-select, with preview of details) - Selected hosts open as new windows in your tmux session
- If run outside tmux, a new session named
sshmxis created - Supports keys, encrypted passwords (via
sshpassafter decryption), jump servers, and optional coloring withchromaterm - Hostnames are resolved to IPs if possible for faster connections
Or use the tmux shortcut: Ctrl+b C-s
Organize sessions by adding a group field when using --add.
To connect to all in a group:
sshmx --groupsor
sshmx -gfzfshows unique groups with preview of sessions in each- Select one or more groups; all sessions in them open as tmux windows
- Or use tmux shortcut:
Ctrl+b C-g
sshmx --addor
sshmx -aPrompts for session name, hostname/IP, user (default: current), port (default: 22), private key (optional), password (optional, will be encrypted with GPG), jump server (optional), group (optional).
Appends to sessions.json.
sshmx --removeor
sshmx -rLets you multi-select sessions to delete using fzf (with preview).
A timestamped backup of sessions.json is automatically created.
sshmx --syncor
sshmx -sParses ~/.ssh/config for Host blocks (HostName, User, Port, IdentityFile, ProxyJump).
Updates or adds sessions in ~/.ssh/sessions.json, preserving existing passwords and groups.
Resolves hostnames to IPs if possible. Logs details to ~/.sshmx.log.
Use Multiplex to combine multiple active SSH windows into a single tmux window with synchronized input enabled β allowing commands to be run on all selected hosts simultaneously.
sshmx --multiplexor
sshmx -mThen, to Demultiplex and restore each hostβs pane back to a separate window:
sshmx --demultiplexor
sshmx -dThis workflow lets you easily switch between centralized control and individual host sessions.
Export:
sshmx --exportor
sshmx -ePrompts for filename (default: sessions-backup-YYYYMMDD_HHMMSS.json); copies sessions.json there.
Import:
sshmx --import /path/to/file.jsonor
sshmx -i /path/to/file.jsonBacks up current sessions.json, then overwrites with the import file.
If you previously stored plain-text passwords in ~/.ssh/sessions.json, you can securely encrypt them using:
sshmx --migrate-passwordsThis command:
- Finds any
passwordfields insessions.json - Encrypts them using GPG and replaces them with
password_encrypted - Deletes the old plain-text password entries
- Exits immediately after completing the migration
β οΈ This command should only be needed once after upgrading from older versions.
The script supports optional background and foreground color settings for each SSH session. When both bg_color and fg_color are defined in your sessions.json, sshmx will:
- Create the tmux window with the specified colors.
- Apply
window-styleandwindow-active-styleso the window appears with those colors.
Example entry in sessions.json:
{
"myserver": {
"host": "example.com",
"user": "user",
"port": 22,
"key": "~/.ssh/id_rsa",
"bg_color": "black",
"fg_color": "green"
}
}Note: Colors must be valid tmux color names or hex codes.
- Press
Ctrl+b C-s(orC-gfor groups) inside tmux fzfshows your saved sessions (or groups) with previews- Select one or more
- New tmux windows open, each running SSH into the chosen host(s)
~/.ssh/sessions.jsonβ Stores your SSH sessions in JSON format:{ "session_name": { "host": "...", "user": "...", "port": 22, "key": "...", "password_encrypted": "...", "jump": "...", "group": "...", "bg_color": "", "fg_color": "" } }~/.sshmx.logβ Log file with parsing and sync details~/.tmux.confβ Key bindings automatically added here~/.local/bin/sshmxβ Symlink to the script for global usage
- Passwords are stored encrypted in
sessions.json(fieldpassword_encrypted) when provided; they are encrypted with GPG. Plainβtext passwords are no longer used. β Highly recommended to use SSH keys instead (IdentityFilein config or key field) - Temporary configs for jump hosts are auto-cleaned (shredded) after use
- Use export/import carefully; always review backups
- For production, consider encrypting the JSON file or using a secure vault
- Encrypted session store (e.g., with gpg or pass)
- On-demand sync with
~/.ssh/config(-s / --sync) - Advanced UI with fzf preview
- Grouped sessions (connect to multiple related servers at once with
-g) - Multiplex commands (run the same command across selected hosts)
- Export/import session configs (share with teammates via
-e/-p) - Custom background/foreground color to seperate envs
| Shortcut | Action |
|---|---|
Ctrl+b C-s |
Open session selector |
Ctrl+b C-g |
Open group selector |
Ctrl+b C-m |
Open multiplex selector |
Ctrl+b C-q |
Demultiplex panes back to separate windows |
Pull requests are welcome!
If you find a bug or want a feature, open an issue.
MIT License Β© 2025 mrbooshehri