1

I try to set up an ec2-instance using Ansible. But it fails when I try to ssh for it. The security group is containing port 22.

We reached our maximum of elastisch IP's at the moment. So I want to know if there's something wrong with my script or isn't it possible to ssh to an instance without an elastic IP?

lova
  • 679
  • 4
  • 8
  • 19
  • Upvoted as this is a very valuable question, and in some ways deeply related to certain types of programming. – jayunit100 Dec 15 '17 at 14:06

2 Answers2

3

Your instance won't NEED an elastic IP. You'll get a public IP if you put the VM in your default VPC. But note that this IP might and will change if you reboot the instance.

In short, no you won't need an elastic ip, but it's very handy.

Exelian
  • 5,749
  • 1
  • 30
  • 49
  • at the moment I have a VPC with an instance with a public dns name and a public ip but I'm not able to ssh – lova Mar 15 '16 at 15:27
  • @lova are you sure the security group the instance belongs to has port 22 open? – Mark B Mar 15 '16 at 15:28
  • Yes it's open. I'm able to see which security group it's using and 22 is open – lova Mar 15 '16 at 15:29
  • I'm not able to click on the public IP. Is that normal? – lova Mar 15 '16 at 15:32
  • Yes, if the public IP is not Elastic you cannot click on it. Please also see my comment on your post. – Exelian Mar 15 '16 at 16:07
  • 1
    Is it true that only the default VPC allows you to have a public IP without an elastic IP? If yes, what's the point of such limitation? – tolache Apr 13 '22 at 12:12
  • Only the default VPC can have public IP's by default. You can create instances with public IP's in any VPC but you'll need to explicitly specify it. – Exelian Apr 13 '22 at 12:58
1

Your instance either needs an Elastic IP, or it needs to be in a public VPC subnet with a public IP.

You can also have Ansible go through an instance it has SSH access to in order to get into the VPC and get access to your other instances. Here is a blog post about this process: http://blog.scottlowe.org/2015/12/24/running-ansible-through-ssh-bastion-host/ If you search for "Ansible ssh bastion host" you will find lots of articles on this topic.

Mark B
  • 183,023
  • 24
  • 297
  • 295
  • at the moment I have a VPC with an instance with a public dns name and a public ip but I'm not able to ssh. What could be the issue? (I have the right key etc.) – lova Mar 15 '16 at 15:28
  • 1
    What type of instance is it? Are you sure there is an ssh daemon running? – ben_979 Mar 15 '16 at 15:57
  • 1
    What does the systemlog say? You can find this by right-clicking the instances, hovering over Instances settings and selecting "Get system log". – Exelian Mar 15 '16 at 16:06