Skip to content
Wrapper around AWS Session Manager to establish ssh sessions using public ip, private ip and instance id
Shell
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md
ec2-ssh.sh

README.md

ec2-ssh

Wrapper around AWS Session Manager to establish ssh sessions using public ip, private ip and instance id

Usage

SSH to instances using SSM Session Manager.
usage: ec2-ssh [-ip | --public-ip || -pip | --private-ip || -id | --instance-id] [-r | --region] [-p | --profile]
   
To see help text, you can run   
   
ec2-ssh [-h | --help]  Help for running this script.
   
required flags:
  -ip || -pip || id       IP Address, Private IP or Instance ID of the instance to do SSH
  -r (default: us-east-1) Region in which instance resides
  -p (default: None)      Profile for aws ssm session manager
   
ec2-ssh: error: the following arguments are required: [-ip | --public-ip || -pip | --private-ip || -id | --instance-id] [-r | --region] [-p | --profile]

Example Usage

  • Using Public IP: ec2-ssh --profile=<your_aws_profile> --region=<ec2_aws_region> --public-ip=<public_ip_for_instance>

  • Using Private IP: ec2-ssh --profile=<your_aws_profile> --region=<ec2_aws_region> --private-ip=<private_ip_for_instance>

  • Using Instance ID: ec2-ssh --profile=<your_aws_profile> --region=<ec2_aws_region> --instance-id=<instance_id_for_instance>

  • Short using Public IP: ec2-ssh -p=<your_aws_profile> -r=<ec2_aws_region> -ip=<public_ip_for_instance>

  • Short using Private IP: ec2-ssh -p=<your_aws_profile> -r=<ec2_aws_region> -pip=<private_ip_for_instance>

  • Short using Instance ID: ec2-ssh -p=<your_aws_profile> -r=<ec2_aws_region> -id=<instance_id_for_instance>

Pro-Tip 💯

  • Move the script to /usr/local/bin or any path which is in global PATH variable so that you can use ec2-ssh instead of giving absolute path.

Prerequisites

You can’t perform that action at this time.