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
Metadata
Release files for managed-ssh 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| managed_ssh-0.1.1.tar.gz | 13.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| managed_ssh-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.5 kB
Release files / managed_ssh-0.1.1.tar.gz
| Download URL | managed_ssh-0.1.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e8607d26a0c0997fafa17a88bd5485fbe17d009e6d29e93f79e18dc49d3cf81
|
|
BLAKE2b-256 checksum How to use checksums |
6ae239f56e0c4a45796e78e133a17f4578343697e8ba044ec8fcbb6bb6d92570
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Release files / managed_ssh-0.1.1-py3-none-any.whl
| Download URL | managed_ssh-0.1.1-py3-none-any.whl |
|---|---|
| Size | 16.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0895613a2a36dc93d79c6c5296d2bc22f94cd4861198f63d13155803e5263130
|
|
BLAKE2b-256 checksum How to use checksums |
b0d8d40eaab6cab0642627cc0dc4119d1a27273ae6e908e5a862e7aeadcbe762
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.9
|
Security for managed-ssh 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.