Skip to content

Instantly share code, notes, and snippets.

@drbh
Created November 16, 2017 18:03
Show Gist options
  • Save drbh/45772264edd81ff654f4197718f8baca to your computer and use it in GitHub Desktop.
Save drbh/45772264edd81ff654f4197718f8baca to your computer and use it in GitHub Desktop.
A CLI app that makes it easy to SSH into a EC2 instance
#!/bin/bash
# Ask the user for their name
echo 'Hello, I will help you connect to your EC2 instance.
You will need 3 pieces of information:
Username
Host Address
Path to key file\n\n'
read -n 1 -s -r -p "[Press any key to continue]"
echo '\n\n'
echo 'Username (OS specific. eg Ubuntu:ubuntu AmazonLinux:ec2-user)'
read username
echo 'Host-name (address eg. ec2-35-182-252-128.ca-central-1.compute.amazonaws.com)'
read host
echo 'Key Location (path eg. ~/Keys/your-key.pem)'
read key
chmod 400 $key
ssh -i $key $username@$host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment