Skip to main content

connect to ec2

Project description

# ec2ssh Python script to facilitate SSH access to AWS EC2 instances with dynamic IPs or behind bastion hosts

ec2ssh uses subprocess.call to connect via SSH to EC2 instances on Amazon Web Services and Boto 3 to get the curret public static IP address of the instance. This way you don’t have to allocate an Elastic IP Address to conveniently connect via SSH to the instance, or repeatedly check it’s current static IP address.

This script is in extremely early stage, but it works (I’m currently using it). It’s mostly a way for me to start using and learning Python.

To get the static IP address of the instance and connect you have to provide the program with an identity file with the following information: * Path to the key pair file for the host * User * EC2 Instance ID

Also, Boto 3 must be able to call the AWS EC2 API, which requires AWS credentials. Ideally, you should install the AWS CLI (sudo pip install awscli) and configure it with your credentials (aws configure).

ec2ssh also supports SSH connections via a bastion host, in which case the identity file must also contain the path to the bastion host key pair, the user for the bastion host and the EC2 Instance ID of the bastion host.

What it’s curretly lacking: * A cli command to create a new identity file (which will ask you if you are using a bastion host or not, followed by the required data) * It does not check for any kind of error or exception * It’s not a Python module yet, it’s just a .py script file; ideally it will install itself via pip in the Python modules folder (the identity files will be saved there too)

Feel free to contribute or comment my code!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ec2ssh-1.2.1.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

ec2ssh-1.2.1-py3.4.egg (6.5 kB view details)

Uploaded Source

File details

Details for the file ec2ssh-1.2.1.tar.gz.

File metadata

  • Download URL: ec2ssh-1.2.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ec2ssh-1.2.1.tar.gz
Algorithm Hash digest
SHA256 944aca2c877ea92aa18dded6bd553ea6ef5b354e51489cb7955736efe83ed58a
MD5 16dc9b25046642b392e8f22ffa21473c
BLAKE2b-256 b378967a64c7060ffb1d600b9d6ac4a2d322896e3ef4f23a9cc3d561375988ec

See more details on using hashes here.

Provenance

File details

Details for the file ec2ssh-1.2.1-py3.4.egg.

File metadata

  • Download URL: ec2ssh-1.2.1-py3.4.egg
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ec2ssh-1.2.1-py3.4.egg
Algorithm Hash digest
SHA256 53cf5317b93f799b449590fd53e09ee087354e71aff69165c559a041897fc5d6
MD5 433a8b8213fdde64be01b78b575d1037
BLAKE2b-256 d10bc552abd87306ef91b4a28a0009b5c1fe2a5b4fa77db5bd6c198443145e90

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page