SSH Config Manager is a modern CLI tool built with Python to simplify the management of your SSH configuration file (~/.ssh/config). With this tool, you can easily add, list, search, edit, and delete SSH entries, all from the command line.
- Add SSH Entries: Add new SSH configurations with ease.
- List SSH Entries: Display all SSH entries in a clean table format.
- Search SSH Entries: Search for hosts by name or hostname.
- Edit SSH Entries: Modify specific fields of an existing SSH entry.
- Delete SSH Entries: Safely remove unwanted SSH entries.
- Verbose Output: View detailed information about each SSH entry.
- Automatic Backups: Creates timestamped backups before any write operation.
- Input Validation: Validates hostnames, IP addresses, ports, and identity files.
- Include Directive Support: Manage
~/.ssh/config.d/include files. - Shell Completion: Bash, Zsh, and Fish completion support via
argcomplete. - Modern CLI Design: Beautifully formatted tables with colorized output using
rich. - Modern Python Packaging: Installable via
pipxwithpyproject.toml. - Comprehensive Test Suite: 40+ tests with pytest.
- Python 3.8 or higher
pip(Python package manager)pipx(recommended for isolated CLI tool installation)
# Install pipx if not already installed
# Arch: sudo pacman -S python-pipx
# Debian/Ubuntu: sudo apt install python3-pipx
# macOS: brew install pipx
# Install ssh-config-manager
pipx install git+https://github.com/zietbukuel/ssh-config-manager.git
# Verify installation
ssh-manager --helpgit clone https://github.com/zietbukuel/ssh-config-manager.git
cd ssh-config-manager
pip install -e .[dev,completion]# Using the provided PKGBUILD
git clone https://github.com/zietbukuel/ssh-config-manager.git
cd ssh-config-manager
makepkg -siNote: The old
install.shscript copied the script to/usr/local/binwhich required sudo. The modernpipxinstallation method installs to an isolated user directory (~/.local/pipx/venvs/...) with a symlink in~/.local/bin— no sudo needed!
Generate and install shell completions for a better CLI experience:
# Bash
ssh-manager completion bash > ~/.bash_completion.d/ssh-manager
source ~/.bash_completion.d/ssh-manager
# Zsh
ssh-manager completion zsh > ~/.zsh/completions/_ssh-manager
# Add to .zshrc: fpath=(~/.zsh/completions $fpath)
# Then run: compinit
# Fish
ssh-manager completion fish > ~/.config/fish/completions/ssh-manager.fish
# Or enable argcomplete globally (works for bash, zsh, fish):
pipx inject ssh-config-manager argcomplete
eval "$(register-python-argcomplete ssh-manager)"The tool supports several commands for managing SSH config entries.
Add a new SSH entry to your ~/.ssh/config file.
ssh-manager add <host> <hostname> <user> <port> [--identity-file <path>]Example:
ssh-manager add myserver 192.168.80.204 root 22 --identity-file ~/.ssh/keyfile.keyDisplay all SSH entries in a clean table format.
ssh-manager listFor verbose output (includes additional fields like IdentityFile):
ssh-manager list -vSearch for SSH entries by host alias or hostname.
ssh-manager search <query>Example:
ssh-manager search myserverDisplay detailed information about a specific host.
ssh-manager show <host>Example:
ssh-manager show myserverModify a specific field of an existing SSH entry.
ssh-manager edit <host> <field> <value>Fields: hostname, user, port, identityfile
Example:
ssh-manager edit myserver user admin
ssh-manager edit myserver port 2222
ssh-manager edit myserver identityfile ~/.ssh/new_keyRemove an SSH entry from your ~/.ssh/config file.
ssh-manager delete <host>Example:
ssh-manager delete myserverManage modular SSH config files in ~/.ssh/config.d/.
List include files:
ssh-manager include-listAdd a new include file:
ssh-manager include-add myserver "Host myserver\n HostName 10.0.0.1\n User admin\n Port 2222"Show an include file:
ssh-manager include-show myserverSSH Config Entries
┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━┓
┃ Host ┃ Hostname ┃ User ┃ Port ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━┩
│ myserver │ 192.168.80.204 │ root │ 22 │
├──────────┼──────────────────┼───────┼──────┤
│ filesrvr │ 192.168.101.99 │ admin │ 22 │
└──────────┴──────────────────┴───────┴──────┘
SSH Config Entries
┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Host ┃ Hostname ┃ User ┃ Port ┃ IdentityFile ┃
┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ myserver │ 192.168.80.204 │ root │ 22 │ ~/.ssh/keyfile.key │
├────────────┼──────────────────┼───────┼──────┼────────────────────────────────┤
│ fileserver │ 192.168.101.99 │ admin │ 22 │ N/A │
└────────────┴──────────────────┴───────┴──────┴────────────────────────────────┘
Search Results for 'myserver'
┏━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━┳━━━━━━┓
┃ Host ┃ Hostname ┃ User ┃ Port ┃
┡━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━╇━━━━━━┩
│ myserver │ 192.168.80.204 │ root │ 22 │
└──────────┴──────────────────┴───────┴──────┘
Details for Host 'myserver'
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Field ┃ Value ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ Hostname │ 192.168.80.204 │
│ User │ root │
│ Port │ 22 │
│ Identityfile │ ~/.ssh/keyfile.key │
└──────────────────┴──────────────────────────────────┘
Include Files
┏━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━┓
┃ File ┃ Size ┃
┡━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━┩
│ myserver.conf │ 58 bytes │
└──────────────────┴──────────┘
The tool performs comprehensive validation before making changes:
| Validation | Description |
|---|---|
| Hostname/IP | Validates IPv4, IPv6, and DNS hostnames (RFC compliant) |
| Port | Must be between 1 and 65535 |
| Identity File | Must exist and be readable |
| Host Alias | Cannot be empty or contain spaces |
| Duplicates | Prevents adding duplicate host aliases |
Before every write operation, a timestamped backup is created at:
~/.ssh/backups/config.backup.YYYYMMDD_HHMMSS
You can restore a backup manually if needed:
cp ~/.ssh/backups/config.backup.20260706_145311 ~/.ssh/configssh-config-manager/
├── ssh_manager.py # Main CLI application (single file)
├── pyproject.toml # Modern Python packaging config
├── tests/
│ └── test_ssh_manager.py # Comprehensive test suite (40 tests)
├── PKGBUILD # Arch Linux package build script
├── README.md # This file
├── LICENSE # MIT License
└── requirements.txt # Legacy requirements (deprecated)
git clone https://github.com/zietbukuel/ssh-config-manager.git
cd ssh-config-manager
pip install -e .[dev,completion]# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=ssh_manager --cov-report=term-missing
# Run specific test class
pytest tests/test_ssh_manager.py::TestValidation -v# Lint with ruff
ruff check .
# Type check with mypy
mypy ssh_manager.pyrich>=13.7.0— Beautiful terminal formattingsshconf>=0.1.0— SSH config parsing
pytest>=7.4.0— Testing frameworkpytest-cov>=4.1.0— Coverage reportingpytest-mock>=3.11.0— Mocking utilitiesruff>=0.1.0— Fast Python lintermypy>=1.5.0— Static type checker
argcomplete>=3.0.0— Shell completion support
Contributions are welcome! If you find a bug or have a feature request, please open an issue or submit a pull request.
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests:
pytest tests/ -v - Submit a PR
This project is licensed under the MIT License. See the LICENSE file for details.
Created by Juan Timaná.
- Modern packaging: Migrated to
pyproject.tomlwithpipxsupport - Automatic backups: Timestamped backups before every write
- Input validation: Hostname/IP, port, identity file, host alias validation
- Include directive support: Manage
~/.ssh/config.d/files - Shell completion: Bash, Zsh, Fish via
argcomplete+completioncommand - Comprehensive tests: 40 tests covering all functionality
- Code quality: Added
ruff,mypy,pytest-covconfigs - Single-file CLI: Refactored
ssh_manager.pywith type hints
- Initial release with basic CRUD operations
- Rich table output
- Basic validation