0
votes

I'm trying to SSH into an EC2 instance using a command like this:

ssh -i ~/.ssh/mykey.pem ubuntu@<ec2_public_DNS_name>

But, the PublicDnsName field is showing up blank on the command line after I create the instance. I have already tried to set DNS Hostnames to yes in the VPC dashboard (and then terminated and created another instance). I have also checked the subnet and Auto-Assign public IP is set to yes.

Where can I find the public DNS name?

1
instead of dns, if you have a public ip then you that. - user156327
step 1: did you succeed in getting into the instance via the ssh given you in the "Connect" tab? - twg
When you enable Auto-Assign public IP, you never get a public DNS name. You get a public IP only. If you need public DNS, you need to create an EIP and associate it to your EC2 instance - krishna_mee2004

1 Answers

2
votes

From what you've described, your instance has probably been stopped. If you're using AWS Command-Line Interface (CLI), you can query your instance details including its public DNS hostname if you know your instance ID:

aws ec2 describe-instances --instance-ids i-XXXXXXXX

Or, if you only know the AMI ID your instance was created from:

aws ec2 describe-instances --filters "Name=image-id,Values=ami-XXXXXXXX"

You should also be able to review all instances owned by your AWS account by visiting AWS EC2 dashboard from a browser.