ssh Connection refused: how to troubleshoot?
Solution 1
You don't have an SSH daemon running. If you look at the output from the ps ax
command, you see that the only two processes with 'ssh' in the description are ssh-agent
(which does something entirely different from sshd
) and the grep ssh
process that you're using to filter the output of ps
.
Depending on what distribution installed, you may need to install or run the ssh
server, usually called openssh-server
or sshd
depending on your package manager.
Solution 2
Steps for debugging the above problem:
Use
nmap
tool to know which ports are open in that server.nmap
is a port scanner. Since it may be possible that ssh server is running on a different port.nmap
will give you a list of ports which are open.$ nmap myserver
2 . Now you can check which server is running on a given port. Suppose in the output of nmap, port 2424 is open. Now you can which server is running on 2424 by using nc(netcat) tool.
$ nc -v -nn myserver portno
Suppose the output of 2424 port is:
myserver 2424 open
SSH-2.0-OpenSSH_5.5p1 Debian-4ubuntu5
This means ssh is running on 2424.
Keep on changing the portno in the above command and check for all the ports which are listed open by nmap.
Solution 3
That means either the ssh server isn't running on that machine or the firewall isn't allowing ssh through. You can check if ssh is running with 'ps -ax | grep ssh'.
Solution 4
The previous two options are good. You can also use the -v
or -vv
arguments.
$ ssh -vv eric@myserver
Eric Wilson
Updated on September 18, 2022Comments
-
Eric Wilson over 1 year
I'm trying:
$ ssh eric@myserver
where
myserver
is a machine in the intranet. I can pingmyserver
or respond to HTTP on port 8080, etc, but when I tryssh
, I getssh: connect to host myserver port 22: Connection refused
I'm using Ubuntu 10.
ps -ax
, as suggested gives:eric@Isaiah:~$ ps -ax | grep ssh Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html 1641 ? Ss 0:04 /usr/bin/ssh-agent /usr/bin/dbus-launch --exit-with-session gnome-session 18376 pts/3 S+ 0:00 grep --color=auto ssh
-
Eric Wilson over 12 yearsEdited question to show results of
ps -ax
. Not sure what it means. -
ChrisCornwall over 12 yearsIt means
ssh
is not running. -
Eric Wilson over 12 yearsWeird. I'm not sure why you have twice now offered help that is not really helpful. First you suggest a command useful to check if ssh is running, without telling me how to interpret the results. Then you provide the minimal interpretation of those results, without a hint as to how you arrived at that interpretation, or what action might be appropriate. I'm not sure whether you are trying to help me, and are misjudging my level of experience, or if you are trying to highlight my ignorance.
-
ChrisCornwall over 12 yearsThe list of processes does not include an
sshd
process, which meanssshd
is not running. The solution is to startsshd
.