We are running ubuntu 14.04 with openssh client & server installed. However when trying to connect to port 22 we get 'connect to host localhost port 22: Connection refused’.
Port 22 is open on our firewall, which we thought would've solved our issue.
We have added rules to ufw and purged/reinstalled openssh. When using the command ‘sudo service ssh status’
it says ssh is running however when using commands ‘netstat'
, 'ps -A | grep sshd'
, 'sudo ss –lnp | grep sshd’
we get no message. When testing ‘ssh –v localhost’
we also get connection refused.
We have restarted ssh many times but the problem still remains.
Also when we use the command 'sudo iptables -L'
we get the following output:
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
We also ran the command sudo netstat -tulpn
and this is what we get:
tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5939 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN -
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp6 0 0 :::139 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
tcp6 0 0 :::445 :::* LISTEN - tcp 0 0 0.0.0.0:139 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:5939 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN -
tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:445 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN -
tcp6 0 0 :::139 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 ::1:631 :::* LISTEN -
tcp6 0 0 :::445 :::* LISTEN -
EDIT/UPDATE
The port 22 is now listening but we get the following error when trying to connect via ssh on a mac, localhost ssh works:
Ubuntu 14.04.2 LTS
Permission denied (publickey).