SSH Shortcut Manager is a Python-based tool to manage and connect to SSH sessions using shortcuts. It supports both interactive and command-line modes, allowing you to assign shortcuts to SSH commands and use them directly in your terminal. The tool automatically adds these shortcuts as aliases in your shell (~/.bashrc and ~/.zshrc), making them available across sessions.
-
Interactive Mode:
- Search and filter SSH connections.
- Assign or edit shortcuts for SSH sessions.
- Directly connect to SSH sessions from the interactive UI.
-
Command-Line Mode:
- Use shortcuts directly from the terminal (e.g.,
sshmgm --shortcut tp-1).
- Use shortcuts directly from the terminal (e.g.,
-
Shell Alias Management:
- Automatically creates or updates aliases in
~/.bashrcand~/.zshrc. - Ensures the aliases persist across sessions.
- Automatically creates or updates aliases in
-
Dynamic Management:
- Prevents duplicate shortcuts.
- Replaces existing shortcuts in shell configurations.
- Python 3.7 or higher
- Pip (Python package manager)
- Bash or Zsh shell
-
Clone the repository:
git clone https://github.com/htayanloo/SSH-Manager.git cd SSH-Manager -
Install the package:
pip install . -
Verify the installation:
sshmgm --help
Run the tool interactively:
sshmgm- Search (s): Search for SSH connections by keywords.
- Select (number): Select an SSH connection to connect or edit its shortcut.
- Shortcut (sc): Directly connect using a shortcut.
- Back (b): Return to the full list.
- Quit (q): Exit the tool.
- Connect (c): Start an SSH session for the selected item.
- Set Shortcut (ss): Assign or update a shortcut for the selected session.
Run the tool with a shortcut directly from the terminal:
sshmgm --shortcut <shortcut>Example:
sshmgm --shortcut tp-1When you assign a shortcut, the tool automatically creates or updates an alias in your shell configuration files (~/.bashrc and ~/.zshrc).
-
Example alias added to
~/.bashrcand~/.zshrc:alias tp-1='ssh user@192.168.1.1'
-
Run the alias directly in the terminal:
tp-1
The tool ensures existing aliases are replaced and configurations are reloaded, making the shortcuts available immediately.
SSH session data is stored in ~/.autossh/ssh_connections.json. This file is managed automatically by the tool.
Example structure:
[
{
"server_ip": "192.168.1.1",
"user": "root",
"port": "22",
"type": "default",
"raw_command": "ssh root@192.168.1.1",
"shortcut": "tp-1",
"source_file": "bash_history"
},
{
"server_ip": "192.168.1.2",
"user": "admin",
"port": "22",
"type": "proxy",
"raw_command": "ssh admin@192.168.1.2",
"shortcut": "srv2",
"source_file": "zsh_history"
}
]The tool updates your shell configuration files (~/.bashrc and ~/.zshrc) to include aliases for each shortcut.
- Assign
tp-1tossh root@192.168.1.1in interactive mode. - Run the alias:
tp-1
- Use the command-line mode to connect:
sshmgm --shortcut tp-1
- Update the shortcut in interactive mode.
- The alias in
~/.bashrcand~/.zshrcis automatically replaced.
To test and run the project locally:
python -m autossh.ssh_manager- Fork and clone the repository.
- Create a new branch:
git checkout -b feature/new-feature
- Make your changes and submit a pull request.
- Python 3.7+
- Bash or Zsh shell
- Dependencies (installed via
pip):rich
This project is licensed under the MIT License. See the LICENSE file for details.
Developed by Hadi Tayanloo. Contributions are welcome! 😊