I cannot seem to SSH into my server on another Port. I have an identical setup on another server, but I am baffled now if my issue is with IPTables or something else. Does anyone see what I am doing wrong?

I am trying to connect via $ ssh [email protected] -p 555 but I keep getting connection refused.

Here are my IP Table Inputs

Attempt 1

This is what I've added (Saved with the iptables-persistent package)

$ sudo iptables -A INPUT -p tcp -m state --state NEW --dport 555 -j ACCEPT

Attempt 2

And I've tried this, and it seems to list in netstat | grep 555 better than the above

$ sudo iptables -A INPUT -p tcp --dport 555 -j ACCEPT

The IPtables List

Then I list it out and it appears to be in there

$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             state NEW tcp dpt:555

Here is my SSHD config

$ head /etc/ssh/sshd_config
# What ports, IPs and protocols we listen for
Port 22
Port 555
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress <--- This has never been an issue for me

Restart SSH

Then I run

$ sudo /etc/init.d/ssh restart
  • What do these commands show: netstat -ln | grep -w 555 sudo lsof -n -R -P | grep -w 555
    – Ian
    Nov 2, 2014 at 23:37
  • It shows TCP 0 0 0.0.0.:555* and IPv4 102514 0t0 TCP *:555 (LISTEN)
    – JREAM
    Nov 3, 2014 at 3:07

1 Answer 1


I would try disable/stop iptables completely and see if you can SSH in then. There may be another rule which is blocking it.

If it's still blocked, try the following on the actual server.

telnet localhost 555

to check the port is open (at least locally, then try site.com/the public IP).

You can also check SSH is listening via

ss -plant | grep ssh

EDIT: Although it seems to be listening from the looks of the netstat output. I'd say it's the firewall blocking SSH access. If possible, flush ALL the rules and then go from there.

  • Well I am baffled at this point. Perhaps my upgrade to 7.7 is giving me problems, I've never had so much trouble with opening a port. Telnet works fine locally, but remotely I can't get in. Weird thing.
    – JREAM
    Nov 4, 2014 at 5:50
  • Does it work if you disable iptables completely? Does telnet locally, via the external IP work?
    – bhavicp
    Nov 4, 2014 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .