Skip to content

Cannot access Mac EC2 instance after turning on Network Sharing

0

Hello,

I have a Mac EC2 instance (id: i-0f94594d956a5470c) that I am trying to remote into via VNC. I recently attempted to expose the EC2 instance to the internet by turning on Network Sharing while tunneled into the remote Mac EC2 instance. Once I did that, the remote viewer froze and I was unable to get back in.

The command I was using to tunnel into the EC2 instance was this one:

ssh -C -N -L 5901:localhost:5900 -i ~/x.pem ec2-user@xx.xx.xx.xx

I have tried rebooting the instance but that did not work. A normal SSH (without the reverse tunneling arguments) seems to time out as well. I have some critical work on the EC2 instance and I want to make sure it is preserved if I need to spin up another instance. I currently have a 100 GB EBS volume attached to it.

asked a year ago275 views
1 Answer
1
Accepted Answer

I understand your concern about accessing your Mac EC2 instance after enabling Network Sharing. This situation can be challenging, but there are several steps we can take to troubleshoot and potentially regain access to your instance.

First, let's ensure that your security group settings are correct. Check that port 22 (for SSH) and port 5900 (for VNC) are open in the inbound rules of the security group associated with your instance. If you're using EC2 Instance Connect, you may need to allow access from the EC2 Instance Connect IP ranges for your region.

Next, verify that your instance has a public IP address. Without a public IP, you won't be able to connect from the internet. If it doesn't have one, you may need to associate an Elastic IP address with your instance.

If these basic checks don't resolve the issue, try connecting using EC2 Instance Connect through the AWS Management Console. This method doesn't require a .pem file and might bypass any SSH configuration issues.

If you're still unable to connect, consider using AWS Systems Manager Session Manager if your instance has the necessary IAM permissions. This can provide an alternative way to access your instance without relying on SSH.

Regarding your data, since you have an EBS volume attached, your data should be safe even if you can't access the instance. If necessary, you can detach this volume and attach it to a new instance to access your files.

If none of these methods work, you may need to stop the instance (not terminate) and start it again. This process will preserve your EBS volume data but may change the public IP address if you're not using an Elastic IP.

As a last resort, if you're still unable to connect, contact AWS Support. They can provide more in-depth assistance and may be able to help you regain access to your instance or at least recover your data.

Remember, for future reference, it's always a good practice to take regular snapshots of your EBS volumes to prevent data loss in situations like this.
Sources
Connect to your Mac instance using SSH or a GUI - Amazon Elastic Compute Cloud
Unable to connect to EC2 Instance | AWS re:Post
SSH access to ec2 fails. | AWS re:Post

answered a year ago
EXPERT
reviewed a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.