CLI tool to help with SSM functionality, aimed at adminstrators
Project description
SSM CLI
A tool to make common tasks with SSM easier. The goal of this project is to help with the Session Manager, the tool tries to keep the access it requires to a minimum.
Installation & Setup
It can be installed with pip install ssm-cli, however most features rely on the session-manager-plugin being installed as well,
this is the standard way to make SSM connections. So a quick few steps here should be followed to avoid any issues.
Step 1. Install Session Manager Plugin
You should be able to install it following the AWS documentation. Please see AWS documentation, to install it. Install the Session Manager plugin for the AWS CLI.
Step 2 (Optional). Install tkinter
ssm-cli makes use of tkinter for the UI selector, on windows this usualy comes pre built with the python binary. On WSL/Linux/MacOS
you may need to install it using the package manager for your distro, (for example with ubuntu sudo apt install python3-tk), further UI
issues may occur with WSL, please see WSLg documentation on this gui-apps
Step 3. Install ssm-cli
You can install this tool to a venv and it will work perfectly fine as well. However I recommend using the global or user space to install it as it makes the ssm command available in default path.
pip install ssm-cli
Step 4. run setup
[!IMPORTANT] Do not skip this step!
The tool installs without any default config and will cause errors when it cannot find the config. To configure the tool you must run the setup action. It will prompt asking for your grouping tag, more infomation on this below.
ssm setup
# or
python -m ssm_cli setup
AWS permissions
The tool uses boto3, so any standard AWS_ environment variables can be used. Also the --profile option can be used similarly to aws cli.
You will need access to a few aws actions, below is a policy which should cover all features used by the tool. However I recommend using conditions in some way to control fine grained access.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "FirstStatement",
"Effect": "Allow",
"Action": [
"resourcegroupstaggingapi:GetResources",
"ssm:DescribeInstanceInformation",
"ssm:StartSession"
],
"Resource": "*"
}
]
}
Config
This tool uses XDG standards on where to store its configuration. Typically this is ~/.config/ssm-cli/ but when running setup it will output the location.
Windows note: the config does not go in AppData like most Windows apps, it lives at ~\.config\ssm-cli\ssm.yaml.
The following files are created by ssm setup:
~/.config/ssm-cli/ssm.yaml, main config (group tag, AWS profile)~/.config/ssm-cli/hostkey.pem, SSH host key used by the proxy feature
If something goes wrong, check the log file at ~/.local/state/ssm-cli/.
Grouping tag
The selecting of instances revolves around a tag on the instance, the tag key can be configured using group_tag_key. The easiest way to test this is setup
properly is to use the list command:
# first list all groups
ssm list
# then list instances in those groups
ssm list my-group
Shell sessions
To connect to an instance:
ssm shell my-group
To exit the session, type exit in the remote shell. Ctrl+C is intentionally passed through to the remote instance rather than closing the session, so it won't disconnect you.
SSH Proxy
The SSH proxy feature lets you use ssm-cli as a transparent tunnel for any tool that supports SSH — including DataGrip, DBeaver, MySQL Workbench, and the regular ssh command. You don't need a traditional bastion host or open inbound ports; traffic routes entirely through AWS SSM.
It works by acting as a local SSH server. When a tool connects through it, ssm-cli opens an SSM port-forwarding session to the target host and bridges the connection.
SSH Config Setup
Add an entry to your SSH config (~/.ssh/config):
Host bastion
ProxyCommand ssm sshproxy bastion_group
This tells SSH that whenever you connect to bastion, it should launch ssm sshproxy as the connection method. You can optionally pass --profile if you use a named AWS profile:
Host bastion
ProxyCommand ssm sshproxy bastion_group --profile your-profile
Using with DataGrip / DBeaver
Tools like DataGrip support SSH tunnels for database connections. Once the SSH config entry above is in place:
- In DataGrip, open your data source and go to the SSH/SSL tab
- Check Use SSH tunnel
- Set Host to
bastion, Port to22, Username tofirstname.lastname - Set Authentication type to
OpenSSH config and authentication agent - DataGrip will pick up the
ProxyCommandfrom your SSH config automatically
The database host field should still point to the internal hostname (e.g. mydb.service.internal), not 127.0.0.1 — DataGrip handles the port forwarding through the tunnel itself.
Using with the ssh command
# forward local port 3306 to an internal database, -N keeps it open without a shell
ssh bastion -L 3306:mydb.service.internal:3306 -N
# then connect to it locally
mysql -h 127.0.0.1 -P 3306
Project details
Release history Release notifications | RSS feed
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 ssm_cli-1.1.0.tar.gz.
File metadata
- Download URL: ssm_cli-1.1.0.tar.gz
- Upload date:
- Size: 27.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e26acfa28a36cc0591b1d19421da6a1bbf5cf03c442e3e55447f70f432e1b6b
|
|
| MD5 |
09c24b1460954f9a40d89a8996f1b6b5
|
|
| BLAKE2b-256 |
7d6f739d0177d4d1720faeb6b51eb7b8f32eed1d1d3f019fe9d886f2cb3cc4cb
|
File details
Details for the file ssm_cli-1.1.0-py3-none-any.whl.
File metadata
- Download URL: ssm_cli-1.1.0-py3-none-any.whl
- Upload date:
- Size: 26.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa647faed59607b564bf43d678babcee4b3bec7d6ae65528a54dab1e7dcda49f
|
|
| MD5 |
65b44f7c2096f543834c46459d0edb5c
|
|
| BLAKE2b-256 |
45621208cdf4d79ef3546a84c7d136762fe19d03826966ed6285b7b23959e1ac
|