Skip to content

Not able to connect from OnPrem/Local machine to EC2 instance.

0

HI Team, I have created an EC2 instance, not able to connect SSH to the EC2 instance. Getting an error message. ssh: connect to host <> port 22: Connection timed out

5 Answers
3

The suggestions provided by the agent are a great starting point. Since you are getting a 'Connection timed out', your packets are being dropped before they reach the OS.

Please verify these additional critical points:

  1. Internet Gateway (IGW): Ensure your EC2 is in a 'Public Subnet'. Your subnet's Route Table must have a route to 0.0.0.0/0 pointing to an Internet Gateway.
  2. Public IP: Confirm that your instance has a Public IPv4 address or an Elastic IP assigned.
  3. Source IP in Security Group: When allowing Port 22, ensure you aren't just using 0.0.0.0/0 (which is insecure) but specifically your current local public IP. You can find it via 'checkip.amazonaws.com'.
  4. Local Corporate Firewall: If you are on an On-Prem/Office network, check if your internal firewall allows outbound traffic on Port 22.

If all else fails, try using EC2 Instance Connect (browser-based) in the AWS Console. If that works, your VPC is fine, and the issue is likely your local network or the specific SSH client configuration.

P.S. Best Practice Recommendation: Instead of troubleshooting SSH and opening Port 22 to the world, consider using AWS Systems Manager Session Manager (SSM).

• Why? It allows you to connect to your instance via the AWS Console or CLI without needing a Public IP, an Internet Gateway, or an open inbound SSH port in your Security Group.

• Requirement: Your instance needs the SSM Agent installed (pre-installed on most Amazon Linux AMIs) and an IAM Instance Profile with the AmazonSSMManagedInstanceCore policy attached.

EXPERT
answered 8 days ago
3

Troubleshooting AWS MGN Agent Installation

It appears the context has shifted from SSH connectivity to AWS Application Migration Service (MGN). The "Unexpected Error" after the sync step usually indicates that the installer cannot communicate with the MGN control plane or the replication staging area. Please verify the following:

  • Outbound Connectivity (Port 443): The source server must be able to reach the MGN shared regional endpoint (mgn.<region>.amazonaws.com) over HTTPS (Port 443). Check your local firewall/proxy settings.
  • Replication Staging Area (Port 1500): The source server needs to communicate with the Replication Servers in AWS on TCP Port 1500.
  • IAM Permissions: Ensure the IAM user/access keys used for the installer have the AWSApplicationMigrationAgentInstallationPolicy attached.
  • Installer Logs: For a specific root cause, check the detailed installation logs on your source machine:
    • Linux: /tmp/aws-replication-installer.log
    • Windows: C:\Program Files\Amazon\Replication\agent_installation.log

Note: As this is a public community forum, AWS experts cannot join private video calls. Please provide the specific error snippet from the log file mentioned above for further help.

EXPERT
answered 7 days ago
1

A "Connection timed out" error when trying to SSH to your EC2 instance typically indicates a network connectivity issue. Here are the key areas to check:

Security Group Rules: The most common cause is missing or incorrect security group rules. You need to verify that your instance's security group has an inbound rule that allows SSH traffic (port 22) from your local machine's public IPv4 address. To check this:

  • Navigate to the EC2 console and select your instance
  • Go to the Security tab and review the Inbound rules
  • Ensure there's a rule allowing traffic from your local computer's IP address to port 22
  • If no such rule exists, add one to your security group

Additional Network Configuration: Beyond security groups, you should also verify:

  • The route table associated with your instance's subnet is properly configured
  • Network ACLs (Access Control Lists) are not blocking the traffic
  • Your instance is in a running state and has passed status checks

Prerequisites: Make sure you're using the correct username for your instance type (for example, "ec2-user" for Amazon Linux, "ubuntu" for Ubuntu instances) and that you have the proper private key file with correct permissions.

If the security group rules are correct, the connection timeout could also indicate issues with your local network firewall, the instance's network configuration, or the subnet's routing setup.
Sources
Troubleshoot issues connecting to your Amazon EC2 Linux instance - Amazon Elastic Compute Cloud

answered 8 days ago
EXPERT
reviewed 8 days ago
0

Is anyone available to have a quick video call ?

answered 8 days ago
0

I have tried with AWS MGN service, its failing at this point.

Command I have used -->

python3 aws-replication-installer-init.py --region us-east-1 --aws-access-key-id <key> --aws-secret-access-key <key>

Error Message: Identified volume for replication: /dev/sdb of size 448 GiB All volumes for replication were successfully identified. Downloading the AWS Replication Agent onto the source server... Finished. Installing the AWS Replication Agent onto the source server... Finished. Syncing the source server with the Application Migration Service Console... Finished.

Unexpected Error Installation failed. Learn more about installation issues in our documentation at https://docs.aws.amazon.com/mgn/latest/ug/Troubleshooting-Agent-Issues.html#Error-Installation-Failed

answered 8 days 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.