A nifty little CLI tool to SSH to EC2 instances using their names
Have you ever done this?
- Login to EC2 Console.
- Search for an instance.
- Copy its IP address.
- Switch to a terminal.
sshand paste in the IP.
- Repeat 2-5 for other instances.
I've been in that situation more times than I care to admit. Enter AWSer: A simple Python script that will make your life 95% easier... at least when it comes to SSH'ing into EC2s!
- Download the
awser.pyscript and place it in a folder in your path.
- [optional] Create a short symlink or alias such as
athat points to the script.
- Install boto3 if you don't already have it installed:
pip3 install boto3 --user
- Make sure you've configured your AWS credentials via
- Start using AWSer!
usage: awser.py [-h] [-r REGION] [-u USER] [-i IDENTITY] keywords [keywords ...] Quickly SSH to EC2 instances by name positional arguments: keywords Keyword(s) to filter list of servers, i.e. 'core 21a' optional arguments: -h, --help show this help message and exit -r REGION, --region REGION Overrides the default AWS region. -u USER, --user USER Specifies a user for SSH. -i IDENTITY, --identity IDENTITY Selects a file from which the identity (private key) is read. -d, --public-dns Use public DNS name instead of IP address to connect.