A set of Python CLI tools to interact with AWS EC2 instances and ECS containers over Systems Manager (SSM). These tools help you quickly list, connect to, and manage AWS resources using AWS named profiles.
SSM and SSMC are interactive CLI tools that leverage AWS Systems Manager Session Manager to provide secure access to your AWS resources. They allow you to:
- Connect to EC2 instances and ECS containers without opening inbound ports
- Send commands to multiple instances in parallel
- Set up port forwarding through SSM tunnels
- Manage ECS containers with interactive shells
- Transfer files securely using SCP
- [Required] AWS SSM agent installed on EC2 instances
- [Required] IAM role with
AmazonSSMManagedInstanceCore
policy attached - [Required] For SSH/SCP features: SSM agent version 2.3.672.0 or later
- [Required] ECS tasks must have the necessary IAM permissions for SSM
- [Required] Container must have a shell available (bash by default)
Required IAM permissions:
ec2:DescribeInstances
ssm:StartSession
ssm:TerminateSession
ssm:DescribeSessions
ssm:DescribeInstanceInformation
ssm:DescribeInstanceProperties
ssm:GetConnectionStatus
ecs:ListClusters
ecs:ListServices
ecs:ListTasks
ecs:DescribeTasks
Optional permissions:
ec2:DescribeRegions
(for cross-region operations)
- Clone the repository:
git clone https://github.com/your-username/ssm-cli.git
cd ssm-cli
- Install the tools:
# Install both tools
make install
# Or install specific tools
make install-ssm # Install only SSM
make install-ssmc # Install only SSMC
ssm [COMMAND] [OPTIONS]
Available commands:
send-command
– Run a shell command on one or more instancesport-forward
– Start local port forwardingport-forward-remote
– Forward a port from the instance to another destinationssh
– Connect to an instance via SSH over SSMscp-to
– Copy files to an instance- (none) – If no command is given, opens an interactive SSM shell
Send a command to multiple instances:
ssm send-command -i i-0123 i-0456 -p myprofile -c 'echo "hello world"'
Port forwarding:
ssm port-forward -i i-0abcd1234efgh5678 -P 8080:3000 --profile myprofile
SSH connection:
ssm ssh -i i-0abcd1234efgh5678 -k ~/.ssh/id_rsa --profile myprofile
ssmc [COMMAND] [OPTIONS]
Available commands:
port-forward
– Start port forwarding to a container- (none) – If no command is given, opens an interactive shell in the container
Connect to a container:
ssmc -p myprofile -c my-cluster -s my-service
Port forwarding to a container:
ssmc port-forward -p myprofile -c my-cluster -s my-service -P 9999:9000
ssm-cli/
├── cli.py # Common CLI utilities
├── ssm.py # EC2 instance management
├── ssmc.py # ECS container management
├── utils/
│ ├── ec2.py # EC2 client utilities
│ └── ecs.py # ECS client utilities
├── Makefile # Build and installation
├── requirements.txt # Python dependencies
└── README.md # This file
MIT License - See LICENSE file for details