One of the struggling issues(as currently), is the ability to SSH to EC2 environment using names. DNS name in EC2 environment is too long. You cannot simply remember EC2 ip addresses. They both change once you reboot or terminate the instance. I feel that one thing we can control is the tag names. Even when the instance is rebooted, the tag names will still be the same.
So, I came up with a small script trying to access the tag name as the host for ssh.
Here is the script.
#!/bin/sh
echo "Enter tag name:"
read tag
instance=`ec2-describe-tags | grep "$tag" | cut -f3`
publicip=`ec2-describe-instances $instance | cut -f17 | tr -d '\n'`
echo $publicip
ssh -i yourpublickey.pem ubuntu@$publicip
Change it to match your environment.
No comments:
Post a Comment