-1

About two weeks ago I was suddenly unable to ssh into my AWS machines, they just time out. Really, the best information I can get from an ssh -vvv <ip> is ssh: connect to host <ip> port 22: Connection refused. if the ip address has changed no one told me about it.

Since I still have the information about the machines from when I set them up, I'm wondering if there's a way to resurrect an AWS cluster using command line tools.

Here is all of the information I have about the machines in the cluster:

- instance IDs
- region
- groupName
- VpcId
- SubnetId
- SubnetId
- public IP addresses

Using the AWS CLI, is there a way to resurrect these instances?

EDIT I'm pretty sure the instances are stopped, judging by this: When I do aws describe-instances --region <region> --instance-ids <id> I see "State" { "Code": 80, "Name": "stopped"}.

  • Is it possible that your IP address changed and you had a security group enabling ssh access only to your old IP address? – Ben Force Apr 5 '17 at 17:37
  • When Ben said is my best guess too, it's your security group or NACL. Open up SSH on 0.0.0.0/0 temporarily and see if you can ssh in. If you can then work out your IP and narrow the range down to a /32. – Tim Apr 5 '17 at 18:58
  • I am not sure about that BenForce and @Tim. I am really new at this, how do I "Open up SSH on 0.0.0.0/0"? – guimption Apr 5 '17 at 20:03
  • docs.aws.amazon.com/AWSEC2/latest/UserGuide/… you need to learn how to use AWS or hire someone, this is a real basic – Tim Apr 5 '17 at 20:14
  • Your question is self-contradictory. Connection refused is not a timeout. And that does make a difference to what are the possible explanations. – kasperd Apr 6 '17 at 6:21
0

You'd want to use reboot-instances. (Assuming you imply, by the use of "resurrect", that they're in a down state and need a reboot. If you mean to imply something other than that, be more specific.)

  • I'm pretty sure the instances are stopped, judging by this: When I do aws describe-instances --region <region> --instance-ids <id> I see "State" { "Code": 80, "Name": "stopped"}. I think that means they are still able to be resurrected right? – guimption Apr 5 '17 at 19:48
0

The command should be: aws ec2 reboot-instances --region $REGION --instance-ids $INSTANCE_ID And replace $REGION and $INSTANCE_ID with the correct information. You will need to have valid session keys for this command to work.

If your instances were in the "Stopped" state (or shut down), they'll lose their public IP addresses (unless they had an Elastic IP attached), so you'll have to run: aws ec2 describe-instances --region $REGION to get a status on all the instances you have permissions to view, and find out their new public IP addresses.

Reference from the AWS CLI Documentation: http://docs.aws.amazon.com/cli/latest/reference/ec2/reboot-instances.html

  • I can't vote yet. +1 though – guimption Apr 5 '17 at 19:43
  • I have the correct boto creds, so I should be fine there. I'll try rebooting the instances to see if they can be recovered. HOWEVER, are you sure that the instance id won't change when they get rebooted??? – guimption Apr 5 '17 at 19:52
  • Instance-id will not change on reboot. They will persist until the instance is terminated (which is AWS's term for deleted). Also, the private IP will persist as well, you only really have to worry about the public IP changing, and even that will persist if you issue the reboot command on a running instance. However, if the instance is "Stopped" (AWS's term for "shut down"), the public IP is released and you can't get it back, you'll just get another random public IP when you start it up again. – Christopher Morrow Apr 6 '17 at 2:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.