EC2 how to swap your elastic IP

1.4k views Asked by At

I have two instances. They are going to run the same app, but one is set up with a slightly different configuration. Right now I can go to their assigned elasticip and see that my site works on both. Th eonly other difference is that one is a micro instance and one is a small instance. Also, I have a bunch of DNS records pointing my domain name to the ip of the micro instance.

But what I want to do is swap them so that the small instance is now my main instance that has my domain pointing to it. I was hoping I could just disassociate the ip's and then reassociate the ip's only flipped around. But when I do that and then try to go to my domain.com I just get an error page. When I swap them back they both seem to work again. Is there something a more complicated I have to do?

edit:

When I try to SSH I also get all this stuff:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
d6:ed:23:65:9c:da:0c:1b:2d:94:34:18:4d:68:8f:a5.
Please contact your system administrator.
Add correct host key in /Users/croberts/.ssh/known_hosts to get rid of this message.
Offending RSA key in /Users/croberts/.ssh/known_hosts:17
RSA host key for 54.183.212.154 has changed and you have requested strict checking.
Host key verification failed.

Something nasty! haha.

2

There are 2 answers

0
John Rotenstein On

The error message is indicating that the remote computer does not match the computer previously recorded in the known_hosts file.

When using ssh, each computer generates a fingerprint and this is recorded against the computer identifier (eg IP Address) that you are using to connect to the remote machine.

If you are switching an Elastic IP address between instances and also using the Elastic IP address to ssh into the instance, then the error quite correctly is warning you that the computer is not the same computer to which you last connected on that address.

You can remove the offending entry from the known_hosts file, or even delete the whole known_hosts file (which admittedly will remove such warnings even if they are legitimate).

0
chris On

You should have no problem swapping the elastic IP from one instance to another. It can take a few minutes to take effect, so make sure that you can reach the correct instance before testing.

You don't describe the error, but if you are using name-based virtual hosts, and are using a different name, that could be one cause. If you restart apache after swapping EIPs, does the problem go away?

Finally, to fix the ssh error, remove the entry from the known_hosts file - if you read the error message, it's on line 17.