Ubuntu ssh connection refused

Ubuntu ssh connection refused can be caused by several factors. This is a guide for Ubuntu ssh connection refused troubleshooting.

1) Check whether ssh is installed in your system using dpkg tool.


luzar@ubuntu:~$ dpkg -l | grep ssh
ii openssh-blacklist 0.1-1ubuntu0.8.04.1 list of blacklisted OpenSSH RSA and DSA keys
ii openssh-client 1:4.7p1-8ubuntu1.2 secure shell client, an rlogin/rsh/rcp repla
ii openssh-server 1:4.7p1-8ubuntu1.2 secure shell server, an rshd replacement
luzar@ubuntu:~$


2) Check ssh daemon is running in your server with ps command.


luzar@ubuntu:~$ ps aux | grep sshd
root 4191 0.0 0.1 5316 1016 ? Ss Nov05 0:00 /usr/sbin/sshd
root 4608 0.0 0.7 11356 3728 ? Ss Nov05 0:00 sshd: luzar [priv]
luzar 4610 0.0 0.3 11512 2036 ? S Nov05 0:02 sshd: luzar@pts/0
luzar 14146 0.0 0.1 3008 776 pts/0 S+ 04:14 0:00 grep sshd
luzar@ubuntu:~$


3) Make sure firewall is not blocking ssh. This is a default Ubuntu iptables with no rules configured.


luzar@ubuntu:~$ sudo iptables -L
Chain INPUT (policy ACCEPT)target prot opt source destination
Chain FORWARD (policy ACCEPT)target prot opt source destination
Chain OUTPUT (policy ACCEPT)target prot opt source destination
luzar@ubuntu:~$


4) Use netstat command to check that ssh is listening on port 22.


luzar@ubuntu:~$ sudo netstat -nap | grep :22
[sudo] password for luzar:
tcp6 0 0 :::22 :::* LISTEN 4191/sshd
tcp6 0 52 192.168.44.128:22 192.168.44.1:1219 ESTABLISHED 4608/sshd:luzar [p
luzar@ubuntu:~$