port 22: Connection refused

0

I'm trying to connect the ec2-machine with ssh through moba but got the error as port 22: Connection refused. Also trying to connect the same ec2 using putty but got the same error as Network Error : Connection refused.

Rahul
질문됨 8달 전1943회 조회
3개 답변
1

Check all these things:

  • the EC2 has a public IP address
  • the EC2 is in a public-facing subnet - that is a subnet which has an entry in its route table to an Internet Gateway
  • the presence of a security group associated with the EC2 allowing inbound access on TCP port 22
  • the absence of a network ACL associated with the subnet that denies inbound access on TCP port 22

More troubleshooting steps, explained in much greater depth, are here https://repost.aws/knowledge-center/ec2-linux-resolve-ssh-connection-errors

profile picture
전문가
Steve_M
답변함 8달 전
profile picture
전문가
검토됨 8달 전
0

Connection refused generally means you don't have the correct security groups configured. Look into your security groups for Inbound Traffic Rules and configure your ip to access on port 22. That should work.

답변함 8달 전
  • I'm trying this as well but issue was not resolved.

0

'Connection Refused' comes remotely from a host. The following are common causes for this error:

  • The host reached the instance but there was no service listening on the SSH port.
  • A firewall blocked and was set to reject the package instead of dropping it.

Performed a telnet and nmap test on your public IP.

Please follow the troubleshooting steps mentioned in the below article in order to resolve this issue. Please go through this is detail. [+] https://repost.aws/knowledge-center/ec2-linux-resolve-ssh-connection-errors

If you do not have EC2 serial console or AWS systems manager configured/enabled on your instance, you may go ahead with 'Method-4' which is using a user-data script.

The listed user-data script clears all the firewall rules and restarts the ssh service on the instance.

IMPORTANT NOTE: 'Method-4' involves stopping and starting your instance which will change the public IP associated with it. In case you do not want that to happen you can allocate an elastic IP to your instance first. For more info on the same, please refer below. [+] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html

I would also recommend you to take an AMI backup of the instance before making any changes to it -

[+] https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/tkv-create-ami-from-instance.html

AWS
지원 엔지니어
답변함 8달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠