Skip to content

SSH not working on fresh account,

0

its fresh account even tried creating new VPS. Security group allowing ssh on port 22 port, subnet, IG, route table etc, but no luck, I've been using AWS since last 7-8 years but never faced such issue, any clue from anyone? no issue connecting other servers on port 22.

asked 2 years ago265 views

3 Answers
0

even tried creating new VPS

One of these? https://aws.amazon.com/what-is/vps/

Or is this a typo and you mean VPC.

If you've created a new VPC then check that the new subnet you've created within it has enabled public IPv4 addresses, and that it's the public, not the private, IP address you're trying to connect to.

Just for troubleshooting, consider opening up inbound port 22 to the world (0.0.0.0/0) and outbound to all ports. You can always tighten these up again later once you've got it working.

As the Gen-AI answer says, if SSH isn't working, can you access using Instance Connect or SSM?

PS I take it the instance is up, and its state is 2/2 (or 3/3) checks passed?

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

  • my bad, I meant VPC and not VPS :) Thanks, mate! My issue just got resolved. I was in the process of submitting my reply when you responded as well. I appreciate your proactive assistance nonetheless!

0

I understand you're experiencing difficulties connecting to your EC2 instance via SSH on a fresh AWS account, despite having experience with AWS. This can be frustrating, but let's go through some potential causes and solutions:

  1. Security Group Configuration: While you mentioned that your security group is allowing SSH on port 22, double-check that the inbound rule is correctly set to allow traffic from your specific IP address or range. Using 0.0.0.0/0 (anywhere) is not recommended for security reasons.

  2. Network ACLs: Ensure that your Network ACLs are not blocking incoming traffic on port 22. Check both inbound and outbound rules.

  3. EC2 Instance Connect: If you're using EC2 Instance Connect, make sure your security group allows traffic from the EC2 Instance Connect IP range for your specific AWS region, not just your own IP address.

  4. Public IP Address: Verify that your EC2 instance has a public IP address assigned and that you're using this address to connect.

  5. Key Pair: Ensure you're using the correct private key that corresponds to the key pair associated with the instance.

  6. Instance State: Confirm that the instance has fully initialized and passed all status checks.

  7. VPC and Subnet Configuration: Double-check that your instance is in a public subnet with a route to an Internet Gateway.

  8. Firewall Settings: If you're able to connect to other servers on port 22 but not this one, it's possible that there might be an OS-level firewall (like iptables) blocking the connection.

  9. Region-specific Issues: If the problem persists, try launching an instance in a different region to rule out any region-specific problems.

If none of these solutions work, you may want to use alternative access methods like AWS Systems Manager Session Manager or EC2 Serial Console to troubleshoot further. If the issue continues, it might be worth contacting AWS Support, as there could be account-specific factors at play.

Remember, when setting up SSH access, it's crucial to follow security best practices. Instead of allowing access from anywhere (0.0.0.0/0), it's recommended to restrict access to specific IP addresses or ranges for production environments.
Sources
Using Security Groups - AWS OpsWorks
Port 22 (SSH) is not authorized | AWS re:Post
ssh: connect to host port 22: Operation timed out | AWS re:Post

answered 2 years ago

AWS
EXPERT

reviewed 2 years ago

0

Thanks, @secondabhi_aws! I managed to resolve the issue.

I noticed that there seems to be some issue with AWS. Port 22 was correctly configured in the inbound rules, and I even allowed access to 0.0.0.0/0. Despite trying multiple times, including deleting and recreating public subnets, the issue persisted.

The problem was only resolved when I modified the inbound rules, replacing the SSH rule with "ALL TCP" access to 0.0.0.0/0. Once connected, I removed the "ALL TCP" rule and added the SSH port rule back, which worked this time.

Interestingly, this same SSH rule had been configured from the start, including in the multiple security groups I created and even the auto-generated security group during instance creation, where access to SSH from anywhere was allowed, but none of them worked initially.

those who stumbled upon this post, please use this workaround,

  1. Go to Security groups, Edit Inbound setting.
  2. Delete SSH rule,
  3. Add "All TCP" connecting from Anywhere (0.0.0.0/0)
  4. Save the Rule, and try connecting again to ssh from your terminal or putty, it should connect
  5. Come back to Security group in Inbound setting, replace "All TCP" with SSH port with source as per your choice and save it,

answered 2 years 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.