a interactive Python CLI tool to help you SSH to your EC2 instances smoothly.
Project description
Welcome to ssh2awsec2 Documentation
ssh2awsec2 is a interactive Python CLI tool to help you SSH to your EC2 instances smoothly.
+----- ⏱ 🟢 Start 'SSH to EC2 instance' ----------------------------------------+
|
| Which EC2 you want to SSH to?
| ⬆ ⬇ Move your cursor up and down and press Enter to select.
[?] Current selection: id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111
> id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111
id = i-0123456789bbbbbbb, name = 'dev-box', public ip = 222.222.222.222
id = i-0123456789ccccccc, name = 'web-app', public ip = 333.333.333.333
| ✅ selected: id = i-0123456789aaaaaaa, name = 'jump-host', public ip = 111.111.111.111
| try to locate pem file ...
| ✅ found pem file at: /Users/myname/ec2-pem/111122223333/us-east-1/dev.pem
| Try to find OS username based on the AMI id = ami-0123456789abcdefg, name = ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server
| cannot automatically detect OS username
| Choose OS username of your EC2, if you don't know, see this document: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html#connection-prereqs-get-info-about-instance
| ⬆ ⬇ Move your cursor up and down and press Enter to select.
[?] Current selection: ubuntu
ec2-user
> ubuntu
fedora
centos
admin
bitnami
root
| Run ssh command: ssh -i /Users/myname/ec2-pem/111122223333/us-east-1/dev.pem ubuntu@111.111.111.111
| Precess Ctrl + D to exit SSH session
Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-1031-aws x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Wed Jun 14 23:28:41 UTC 2023
System load: 0.0 Processes: 104
Usage of /: 52.0% of 19.20GB Users logged in: 0
Memory usage: 7% IPv4 address for ens5: 10.1.1.1
Swap usage: 0%
* Ubuntu Pro delivers the most comprehensive open source security and
compliance features.
https://ubuntu.com/aws/pro
* Introducing Expanded Security Maintenance for Applications.
Receive updates to over 25,000 software packages with your
Ubuntu Pro subscription. Free for personal use.
https://ubuntu.com/aws/pro
Expanded Security Maintenance for Applications is not enabled.
19 updates can be applied immediately.
To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
New release '22.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
2 updates could not be installed automatically. For more details,
see /var/log/unattended-upgrades/unattended-upgrades.log
Last login: Wed Jun 14 23:23:58 2023 from 100.100.100.100
ubuntu@ip-10-1-1-1:~$ logout
Connection to 111.111.111.111 closed.
|
+----- ⏰ 🟢 End 'SSH to EC2 instance', elapsed = 16.35 sec ---------------------+
Usage Example
# show CLI help info
ssh2awsec2
# or use the short name
sshec2
For first usage, you need to configure ssh2awsec2 to locate your AWS CLI credential.
# show config related information
sshec2 info
# show config subcommand help info
sshec2 config
# show current config
sshec2 config show
# set the AWS profile
sshec2 config set-profile --profile <your_aws_profile>
# set to use the default AWS profile
sshec2 config set-profile --profile default
# set cache expire time
sshec2 config set-cache-expire 3600
# clear cache
sshec2 clear-cache
Then you can use sshec2 ssh command to ssh to your AWS EC2 instance. Just follow the interactive prompt:
# show help info
sshec2 ssh --help
# pick an EC2 and ssh into it
sshec2 ssh
# you can use -n to filter EC2 by name tag
sshec2 ssh -n <name_tag_here>
# example
sshec2 ssh -n jump_host
# you can use -i to filter EC2 by instance id
sshec2 ssh -i <full_instance_id_or_chunk_here>
# example
sshec2 ssh -i 1a2b
# you can use -k to filter EC2 by instance id (quote the query string)
sshec2 ssh -k "<name_tag_key_value_pair_here>"
# example
sshec2 ssh -k "env=prod,owner=alice"
It prompt you to select EC2 instance and probably ask for the OS username. The selection will be cached for 24 hours, so you will see it on top of the list next time.
Install
ssh2awsec2 is released on PyPI, so all you need is:
$ pip install ssh2awsec2
To upgrade to latest version:
$ pip install --upgrade ssh2awsec2
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
File details
Details for the file ssh2awsec2-0.1.2.tar.gz
.
File metadata
- Download URL: ssh2awsec2-0.1.2.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d222cc0ecf4e2a0a1118903f048870aca65b9535409679372a8c73b903dede73 |
|
MD5 | c58e17f5e592b64fe893a9691099db64 |
|
BLAKE2b-256 | 3e3e092d26bfdede71c2c110d1075d53d28085ae5d87468cc5b0a7313489325f |
File details
Details for the file ssh2awsec2-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: ssh2awsec2-0.1.2-py3-none-any.whl
- Upload date:
- Size: 24.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 531395ef9bd74176155d97898d3eff5eddded2d1721bc0025a631aeb81845ef6 |
|
MD5 | cd1668f39504347f10c328854137a80f |
|
BLAKE2b-256 | 6badb28c3fbd84e33da52dacd5691bdc60eb028e89b705f875c18f426750767d |