ssh Connection refused: how to troubleshoot?

I’m trying:

$ ssh <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84e1f6ede7c4e9fdf7e1f6f2e1f6">[email protected]</a>

where myserver is a machine in the intranet. I can ping myserver or respond to HTTP on port 8080, etc, but when I try ssh, I get

ssh: connect to host myserver port 22: Connection refused

I’m using Ubuntu 10.

ps -ax, as suggested gives:

<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89d8a919bb8b18b99919990">[email protected]</a>:~$ 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

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 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.

Method 2

Steps for debugging the above problem:

  1. 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.

Method 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’.

Method 4

The previous two options are good. You can also use the -v or -vv arguments.

$ ssh -vv <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ed889f848ead80949e889f9b889f">[email protected]</a>

Method 5

I faced this issue too, but in a VirtualBox environment, so to solve it we need to set the IP address to be in the same LAN segment; for example:

On my host machine,
I open cmd and type ipconfig. I get 100.2.2.1 (for example).

So in the virtual machine we must set the VM’s address in /etc/hosts to a value like 100.2.2.3, take a look in the final number, and bounce the virtual machine, but before start up the virtual machine configure the network in the settings of the virtual machine, so we need to set the network adapter in bridge connection.

All of this is in a Solaris environment.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x