I’m trying to connect to my server via SSH. I get the (well-known) error:
ssh: connect to host 12.345.678.910 port 2222: Connection refused
So I first thought the problem was with my modem, but I’ve verified that port 2222 is open (via http://portchecker.co/check)
The SSH deamon (
sshd.socket
) is also working and listening on port 2222 and I’ve changed my/etc/ssh/sshd_config
to allow connections via port 2222.I think the problem might be with my firewall because
nmap -p 2222 12.345.678.910
shows that port 2222 is closed but host is up.What should I do to allow SSH on my server via port 2222? What other diagnostics can I perform to see what the problem is?
===== EDIT =====
Resolved the issue:
The problem was not any of the above or as suggested in the “This question already has an answer so deal with it” but it had to do with that I was trying to log on to the server from the same network to which the server is connected. I tried to connect to the server from a different network (at university) and this worked perfectly. So is there something restricting me from logging on from the same network (so behind the same modem)?
Answer
It could be your local iptables firewall. try the below command to open port 2222
#iptables -A INPUT -p tcp -m tcp –dport 2222 -j ACCEPT
Attribution
Source : Link , Question Author : MichaelDeSanta , Answer Author : Bhargav