Making EC2 ssh and scp connections easy
Whenever a new instance is started, it gets a random hostname like ec9-99-99-99-99.compute-1.amazonaws.com. These hostnames are hard to remember and don't give any clues about the function of that server, so we use use the EC2 tagging feature to assign meaningful names to our servers, e.g. appserver-testing-1.
So instead of using the automatically assigned hostname it would be awesome if we could just use the tag we assigned ourselves like a hostname. We've been using the tool ec2-ssh by Instagram for this task. It already helped a lot to make things easier, but we missed some stuff like support for scp to copy files or full support for all ssh command line parameters.
So today we want to post about ec2dns which we developed here at the office as a "friday project" (whenever possible, we try to make fridays available to work on interesting projects that are not necessarily directly related to fruux). It is heavily inspired by ec2-ssh and powered by the aws-sdk-for-php. ec2dns is a set of command line tools that makes it easy to display public hostnames of EC2 instances and ssh into them via their tag name.
Our ec2dns tool has full support for ssh, scp and some other stuff that you'll find in the readme.
Some examples on how to use it:
Get a list of your ec2 instances $ ec2host i-12345678: appserver-1 ec9-99-99-99-99.compute-1.amazonaws.com i-87654321: appserver-2 ec1-11-11-11-11.compute-1.amazonaws.com
Get the hostname of an ec2 instance by its name tag $ ec2host appserver-1 ec9-99-99-99-99.compute-1.amazonaws.com
ssh into an instance via its name tag $ ec2ssh appserver-2
copy a file from an ec2 instance onto your machine $ ec2scp ubuntu@appserver-1:/etc/nginx/nginx.conf .
ec2ssh and ec2scp work exactly like ssh and scp, with the only exception that they'll allow you to use your ec2 tags instead of full hostnames. It helps us quite a bit in our daily work here to quickly and easily use ssh and scp with our ec2 instances.
We are committed to open source
We use many open source tools, so naturally we also like the idea of giving back. ec2dns is available on GitHub together with instructions on how to install it with Composer (another great tool we're using a lot and you definitely should check out if you are into php development).
We hope that this tool will be as useful for you as it is for us, and perhaps you'll even help us to improve it. Also make sure to check out our other open source projects.