Log into EC2 instances naturally without having to figure out their public hostname ahead of time!
$ ssh ec2-user@web-prod-1.ec2
Last login: Wed Mar 12 22:06:27 2014
[ec2-user@ip-10-158-37-24 ~]$
#!/bin/bash | |
set -e -u | |
instance_name="$1" | |
port="$2" | |
hostname="$( aws ec2 describe-instances --filters Name=tag:Name,Values=${instance_name%.ec2} | jq -r .Reservations[].Instances[0].PublicDnsName )" | |
exec nc ${hostname} ${port} |
Host *.ec2 | |
ProxyCommand ~/bin/ssh-ec2.sh %h %p |