AWS SSH Extension

If you have a lot of services running over a multitude of instances, or if you just don't want to have to remember IP addresses, this tool will work for you.

Requirements

It does assume that you are using SSH key based authentication to access the servers and have a correctly configured environment. This means a current ~/.ssh/config that has relevant proxy settings etc along with AWS environment vars (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION)

Ruby, version 2.0 onwards, is required along with the standard bundler gem.

At the moment, this code is only tested with bash based shells whose ssh config is setup around their user (non root, local, not global ssh config etc).

AWS Configuration

Before you install this code, please be aware you may need to add some information to your ec2 instances. This code makes use of the "tags" key / value data available for each instance.

I think this will be easier to explain by example:

Above is an ec2 instance setup to run both website and blog services (website.blog) in production and staging (production.staging).

This ec2 instance is just the website running in production.

What values you have for environment and service are free form, so if you prefer to use "prod" instead of "production", you can.

You can also have as many services and environments as you like, they just have to be seperated by a full stop (.).

Install

gem install aws_ssh && aws_ssh_setup

Uninstall

aws_ssh_teardown && gem uninstall aws_ssh

Usage

Once installed you will need to make an SSH call to a service like:

ssh $environment_$service or ssh $service_$environment

In the case or examples above, that would be:

ssh production_website or ssh website_production

To be even more useful, it will also add the instance name, so:

ssh websites

would work as well

If you have tab completion available, even better.

SSH User

By default "deploy" is used as the ssh user. You can override this in the command as you are running it:

ssh my-user@website_production

Or, to save remembering, you can add a "user" tag to your instance and that will be loaded in