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
gefragt vor 8 Monaten1941 Aufrufe
3 Antworten
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
EXPERTE
Steve_M
beantwortet vor 8 Monaten
profile picture
EXPERTE
überprüft vor 8 Monaten
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.

beantwortet vor 8 Monaten
  • 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
SUPPORT-TECHNIKER
beantwortet vor 8 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen