managed-ssh
managed-ssh is a command line SSH manager for saving destinations once and reusing them with short aliases.
Instead of typing the same hosts, user@host targets, and private key paths every time, you can save them in mssh and use the aliases with ssh, scp, and remote commands.
What it helps with
- Save short names for hosts, such as
devbox -> 10.10.10.5. - Save full SSH targets, such as
app -> ubuntu@10.10.10.9. - Attach an SSH private key to an alias and let
msshuse it automatically. - Connect with
mssh access <alias>. - Run remote commands with
mssh remote-run <alias> <command>. - Copy files with
mssh copy, including alias resolution on remote paths. - Export and import aliases as JSON backups.
Requirements
- Python 3.8 or newer.
sshandscpavailable in your systemPATH.
Installation
Install from PyPI:
pip install managed-ssh
After installing, the CLI command is:
mssh --help
Quick Start
Create a host alias:
mssh save-host devbox 10.10.10.5
Connect to it:
mssh access devbox
Use a different login user without creating another alias:
mssh access ubuntu@devbox
Create a target alias when the user is always the same:
mssh save-target app ubuntu@10.10.10.9
mssh access app
Run a command remotely:
mssh remote-run app uname -a
Copy a local file to a saved target:
mssh copy ./local.txt app:/tmp/local.txt
Alias Types
mssh supports two destination alias types:
| Type | Example | Use it when |
|---|---|---|
| Host alias | devbox -> 10.10.10.5 |
You want to reuse the host with different users, such as root@devbox or ubuntu@devbox. |
| Target alias | app -> ubuntu@10.10.10.9 |
You usually connect with one fixed user and host. |
You can also let mssh detect the alias type:
mssh save devbox 10.10.10.5
mssh save app ubuntu@10.10.10.9
SSH Keys
Generate a key in ~/.mssh/keys:
mssh keygen server-a
Generate a key with a passphrase:
mssh keygen server-a "my-passphrase"
Save an alias with a specific key:
mssh save-host devbox 10.10.10.5 --key ~/.ssh/devbox.pem
mssh save-target app ubuntu@10.10.10.9 --key ~/.ssh/app.pem
Set, replace, or remove a key for an existing alias:
mssh set-key app ~/.ssh/app.pem
mssh unset-key app
Override the saved key for a single SSH connection:
mssh access app --key ~/.ssh/temporary.pem
Override the saved key for a single copy:
mssh copy ./local.txt app:/tmp/local.txt --key ~/.ssh/temporary.pem
Copy Files
mssh copy wraps scp and resolves aliases on remote endpoints.
Copy from local to remote:
mssh copy ./local.txt app:/tmp/local.txt
Copy from remote to local:
mssh copy root@devbox:/tmp/file.txt ./file.txt
Copy between two remote destinations:
mssh copy app:/tmp/report.log root@devbox:/tmp/report.log
If both remote sides use aliases with keys, mssh passes the identity files to scp and uses scp -3 so the copy is negotiated from your local machine.
Run Remote Commands
Use remote-run to execute a command through SSH:
mssh remote-run devbox uname -a
mssh remote-run app ls -la /var/www
The destination can be an alias, user@alias, or user@host.
Manage Aliases
List saved aliases:
mssh list
Rename an alias:
mssh rename old-name new-name
Delete an alias:
mssh delete app
Use -y to skip confirmation prompts:
mssh rename old-name new-name -y
mssh delete app -y
Export and Import
Export your aliases to a JSON file:
mssh export --file backup-mssh.json
Import and merge while keeping existing aliases:
mssh import --file backup-mssh.json --skip-existing -y
Import and merge while overwriting conflicts:
mssh import --file backup-mssh.json --overwrite -y
Replace all local aliases with the imported file:
mssh import --file backup-mssh.json --replace -y
Command Reference
| Command | Description |
|---|---|
mssh access <destination> |
Open an SSH session to an alias, user@alias, or user@host. |
mssh remote-run <destination> <cmd1> <cmd2> ... |
Run a remote command through SSH. |
mssh copy <source> <target> |
Copy files with scp and resolve aliases on remote paths. |
mssh keygen <key_name> [passphrase] |
Generate an SSH key under ~/.mssh/keys. |
mssh save-host <alias> <host> [--key <path>] |
Save a host alias. |
mssh save-target <alias> <user@host> [--key <path>] |
Save a target alias. |
mssh save <alias> <value> [--key <path>] |
Save an alias and detect whether the value is a host or target. |
mssh list |
Show saved hosts, targets, and associated keys. |
mssh rename <old_alias> <new_alias> [-y] |
Rename an alias. |
mssh delete <alias> [-y] |
Delete an alias. |
mssh set-key <alias> <path> |
Set or replace the SSH key for an alias. |
mssh unset-key <alias> |
Remove the SSH key associated with an alias. |
mssh export [--file <path>] |
Export aliases to JSON. |
| `mssh import --file | --overwrite |
Where Data Is Stored
Aliases are stored locally in:
~/.mssh/aliases.json
Generated keys are stored under:
~/.mssh/keys
The aliases file uses this structure:
{
"hosts": {
"devbox": "10.10.10.5"
},
"targets": {
"app": "ubuntu@10.10.10.9"
},
"keys": {
"app": "/home/user/.ssh/app.pem"
}
}
Notes
- A name cannot exist as both a host alias and a target alias.
- If an alias already exists,
saveasks for confirmation before overwriting it. - Keys are used automatically when the destination or copy endpoint uses an alias.
--keyoverrides saved alias keys for a single command.managed-sshdoes not replace OpenSSH configuration; it is a small alias manager that calls your systemsshandscpcommands.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file managed_ssh-0.1.1.tar.gz.
File metadata
- Download URL: managed_ssh-0.1.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e8607d26a0c0997fafa17a88bd5485fbe17d009e6d29e93f79e18dc49d3cf81
|
|
| MD5 |
874c5b38694fc753594f6fa9f79241fa
|
|
| BLAKE2b-256 |
6ae239f56e0c4a45796e78e133a17f4578343697e8ba044ec8fcbb6bb6d92570
|
File details
Details for the file managed_ssh-0.1.1-py3-none-any.whl.
File metadata
- Download URL: managed_ssh-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0895613a2a36dc93d79c6c5296d2bc22f94cd4861198f63d13155803e5263130
|
|
| MD5 |
26df439e4186ad6c6e899f2ef2d3dde6
|
|
| BLAKE2b-256 |
b0d8d40eaab6cab0642627cc0dc4119d1a27273ae6e908e5a862e7aeadcbe762
|