A tool that allows you to lazily connect to any of your AWS EC2 instances!
Why use lazyconn?
- No more manually managing ssh config files.
- You won't have to remember IP Addresses.
- Faster & easier to connect to instances w/ dynamic IP Addresses.
- With a proper lazyconn config, you won't have to remember usernames.
- You won't have to remember which key files go to which instances.
- Nice TUI that shows you what you need to know about an instance before connecting.
- Allows you to easily bounce between instances.
Requirements: Docker
Cloning the repo:
git clone https://github.com/brokerage-systems/lazyconn.git
cd lazyconn/
Building with Docker
docker build --build-arg AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXXXX --build-arg AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -t lazyconn .
Note: We attach a docker volume to our .ssh/ directory so lazyconn can read our key files & lazyconn config!
docker run -i --rm -v /home/josh/.ssh/:/root/.ssh/ lazyconn --help
Specifying a region: lazyconn will automatically use the aws cli configured region and if that isn't configured and no region parameter is passed, it will default to us-east-1!
docker run -i --rm -v /home/josh/.ssh/:/root/.ssh/ lazyconn -r us-east-1
Specifying a user: if nothing is specified, there will be a prompt to enter the username
docker run -i --rm -v /home/josh/.ssh/:/root/.ssh/ lazyconn -u ec2-user
Requirements: Python 3 | AWS CLI
If you just installed the AWS CLI, then run the following command:
aws configure
# enter aws access key id, secret access key, default region (optional). (default output format does not need to be configured)
Cloning the repo & Installing dependencies:
git clone https://github.com/brokerage-systems/lazyconn.git
cd lazyconn/
pip install -r requirements.txt
python3 lazyconn.py --help
Specifying a region: lazyconn will automatically use the aws cli configured region and if that isn't configured and no region parameter is passed, it will default to us-east-1!
python3 lazyconn.py -r us-west-2
Specifying a user: if nothing is specified, there will be a prompt to enter the username
python3 lazyconn.py -u ec2-user
Create a config file @ ~/.ssh/lazyconn.json then lazyconn will read this config, loop through all available instances, match the name, then use the configured options to connect to the instance.
{
"match": {
"name": [
{
"contains": "ECS",
"user": "ec2-user"
},
{
"contains": "App",
"user": "ubuntu"
}
]
}
}
Instance List:
┌─────┬─────────────────────┬────────────────────────┬──────────────────────────┬────────────────┬─────────┐
│ # │ ID │ Name │ Type │ IP Address │ Key │
├─────┼─────────────────────┼────────────────────────┼──────────────────────────┼────────────────┼─────────┤
│ 1 │ i-01111111111111111 │ ECS Instance - Website │ (Linux/UNIX) t2.medium │ 123.24.25.250 │ ecs.pem │
├─────┼─────────────────────┼────────────────────────┼──────────────────────────┼────────────────┼─────────┤
│ 2 │ i-02222222222222222 │ App Server │ (Linux/UNIX) t3.medium │ 124.25.26.251 │ ec2.pem │
└─────┴─────────────────────┴────────────────────────┴──────────────────────────┴────────────────┴─────────┘
Pattern example #1 This will connect to the "ECS Instance - Website" instance with the user "ec2-user" automatically.
python3 lazyconn.py -m "Website"
or
docker run -i --rm -v /home/josh/.ssh/:/root/.ssh/ lazyconn -m "Website"
Pattern example #2 This will connect to the "App Server" instance with the user "ubuntu" automatically.
python3 lazyconn.py -m "App"
or
docker run -i --rm -v /home/josh/.ssh/:/root/.ssh/ lazyconn -m "App"