Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get public dns name of a ec2 instance using ec2 command line tools in bash

I have name of the a ec2 instance and want to do ssh to it. How can I figure out the 'Public DNS' of the ec2 instance using the ec2 instance name.

I want to do it using bash.

like image 402
user1788294 Avatar asked Apr 02 '14 14:04

user1788294


People also ask

How do I find my EC2 instance public DNS name?

Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Instances. Select your instance from the list. In the details pane, the Public DNS (IPv4) and Private DNS fields display the DNS hostnames, if applicable.

How do I find the public IP address of my EC2 instance?

To view the IPv4 addresses for an instance using the consoleOpen the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Instances and select your instance. The following information is available on the Networking tab: Public IPv4 address — The public IPv4 address.


1 Answers

aws ec2 describe-instances --instance-ids i-12abc34 --query 'Reservations[].Instances[].PublicDnsName'

Where i-12abc34 is your instance id

like image 120
matt burns Avatar answered Sep 20 '22 01:09

matt burns