Hi I'm having a problem with my ssh, which is magically stopped working and I couldn't figure out why. The message it give is:
ssh: connect to host <host> port 22: Connection refused
I don't see any error messages when I write dmesg
but I'm getting following from telnet localhost 22
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
I tried the solutions that I saw in some similar cases [1] and [2] but it still didn't solve my problem the entries and outputs are as follows:
>> sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
>> sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Note that this was already ACCEPT I didn't had any problem even before entering the command sudo iptables -A INPUT -p tcp --dport ssh -j ACCEPT
. I also tried to reboot ssh but it didn't change anything
>>netstat -a | egrep 'Proto|LISTEN'
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 localhost:20128 *:* LISTEN
tcp 0 0 localhost:17600 *:* LISTEN
tcp 0 0 localhost:20129 *:* LISTEN
tcp 0 0 localhost:17603 *:* LISTEN
tcp 0 0 localhost:21128 *:* LISTEN
tcp 0 0 deathstar:domain *:* LISTEN
tcp 0 0 localhost:ipp *:* LISTEN
tcp 0 0 *:db-lsp *:* LISTEN
tcp6 0 0 ip6-localhost:ipp [::]:* LISTEN
tcp6 0 0 [::]:db-lsp [::]:* LISTEN
I don't know what else to try so hope this is enough to solve the problem.
Rest is added after @Ashu's comment
sudo lsof -i | grep ssh
nothing happened
>>netstat -l --numeric-ports | grep 22
unix 2 [ ACC ] STREAM LISTENING 1618183 @jack-com.canonical.Unity.Master.Scope.files.T1731348652205882
>>sudo iptables --list
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- anywhere anywhere tcp dpt:ssh
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Eddited after @TheSchwa's comment
>>ps aux | grep sshd
jack 3711 0.0 0.0 15944 2220 pts/26 S+ 14:08 0:00 grep --color=auto sshd
telnet localhost 22
? Do you have any way to access the remote machine other thanssh
?ps aux | grep sshd
.