ssh: connect to host xxx.xx.xx.xxxx port 22: connection refused

13 Apr

While configuring Ubuntu for PostgreSQL, when I was trying to connect Ubuntu server, I got following error message:

edbs-MacBook-Pro:~ vibhor$ ssh vibhor@172.16.82.130  
ssh: connect to host 172.16.82.130 port 22: Connection refused  

To resolve this issue, I have found that installation of Ubuntu 10.10 doesn’t have openssh-server installed due to which Message was coming, so I have installed openssh-server using following command as given below:

root@ubuntu:~# apt-get install openssh-server  
Reading package lists... Done  
Building dependency tree         
Reading state information... Done  
The following packages were automatically installed and are no longer required:  
  linux-headers-2.6.35-22 linux-headers-2.6.35-22-generic  
Use 'apt-get autoremove' to remove them.  
Suggested packages:  
  rssh molly-guard openssh-blacklist openssh-blacklist-extra  
The following NEW packages will be installed:  
  openssh-server  
0 upgraded, 1 newly installed, 0 to remove and 7 not upgraded.  
Need to get 302kB of archives.  
After this operation, 819kB of additional disk space will be used.  
Get:1 http://us.archive.ubuntu.com/ubuntu/ maverick-updates/main openssh-server i386 1:5.5p1-4ubuntu5 [302kB]  
Fetched 302kB in 5s (52.0kB/s)           
Preconfiguring packages ...  
Selecting previously deselected package openssh-server.  
(Reading database ... 147353 files and directories currently installed.)  
Unpacking openssh-server (from .../openssh-server_1%3a5.5p1-4ubuntu5_i386.deb) ...  
Processing triggers for ureadahead ...  
Processing triggers for ufw ...  
Processing triggers for man-db ...  
Setting up openssh-server (1:5.5p1-4ubuntu5) ...  
Creating SSH2 RSA key; this may take some time ...  
Creating SSH2 DSA key; this may take some time ...  
 * Stopping OpenBSD Secure Shell server sshd                                                             [ OK ]   
ssh start/running, process 17665  

After installation, I was able to connect to Ubuntu Server:

edbs-MacBook-Pro:~ vibhor$ ssh vibhore@172.16.82.130  
vibhore@172.16.82.130's password:   
Linux ubuntu 2.6.35-28-generic #49-Ubuntu SMP Tue Mar 1 14:40:58 UTC 2011 i686 GNU/Linux  
Ubuntu 10.10  
Welcome to Ubuntu!  
 * Documentation:  https://help.ubuntu.com/  
7 packages can be updated.  
0 updates are security updates.  
  
 
The programs included with the Ubuntu system are free software;  
the exact distribution terms for each program are described in the  
individual files in /usr/share/doc/*/copyright.  
  
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by  
applicable law.  

To fix the above ssh connection issue, user can execute following command to check if ssh daemon is running or not:

ps -eaf|grep sshd  

If sshd is running fine, user can also check if firewall is suppressing the port 22.

netstat -nav|grep :22 

After fixing the issue from firewall, user can restart the services as given below:

/etc/init.d/ssh restart  
About these ads

7 Responses to “ssh: connect to host xxx.xx.xx.xxxx port 22: connection refused”

  1. Tebogo January 18, 2012 at 07:46 #

    Thankx alot man, It worked. i’ve been trying by hard to ssh to my hostname. I did run the openssh and voalla!

  2. Sathish March 17, 2012 at 06:45 #

    I just forgot to enable the service in my remote machine. and i followed your guide its working well. Thanks for the guide..

  3. Praciano-Pereira Tarcisio May 24, 2012 at 23:16 #

    It was nice reading this, I was expecting ssh stuff installed, usually. I have just learned this: sometimes it is not. But after installation all which is need is tell “yes” for the new host you are going to use. For more security it is best to generate public key at both machines, ssh-keygen will do that.

  4. boe var May 11, 2013 at 12:33 #

    Hi Mr. Kumar, I have three desktops with distros CentOS 6, Ubuntu 10, and ScientificLinux 6. I can ssh from each other except from CentOS to Ubuntu, ScientificLinux to Ubuntu, and Ubuntu to itself. I can ssh to CentOS itself and to ScientificLinux itself, but not to Ubuntu itself. I can ssh from CentOS to ScientificLinux and vice-versa. So my problem is on Ubuntu. When I try to ssh from CentOS or ScientificLinux to Ubuntu I get the following error message: “ssh: connect to host xx.xx.xx.xx port 22: Connection refused”. Any help will be appreciated.

    • Database Technologies July 11, 2013 at 01:42 #

      I am guessing it could be due to firewall setting in your ubuntu. Or please check port 22 is listening on your ubuntu machine.

      • satheesh July 18, 2013 at 11:06 #

        thanks! it’s working good!

Trackbacks/Pingbacks

  1. SLAD install issue with openssl key verification - Page 2 - February 29, 2012

    [...] ~/.ssh chmod 600 ~/.ssh/authorized_keys 6. Check that ssh-server is installed on the target machine http://vibhorkumar.wordpress.com/201…ction-refused/ 7. Run the slad installer as normal user on the local machine and it should run and download the [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: