Wednesday, April 13, 2011

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

While configuring Ubuntu for PostgreSQL, when I was trying to connect Ubuntu server, I got following error message:
edbs-MacBook-Pro:~ vibhor$ ssh vibhor@
ssh: connect to host 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:
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 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@
vibhore@'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:
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

No comments:

Post a Comment