breaking into the unknown…

ssh Connection refused port 22

Leave a comment

Recently, I have to automate my rails deployment. I want to first replicate my deployment script on my friend machine. So nothing should go wrong in the real server. So, I tried to ssh to my friend machine whose address is suresh@, but welcomed by the error message.

$ ssh suresh@
ssh: connect to host port 22: Connection refused

I thought,  the target machine is not accessible on my network, but I was wrong, when I pinged the machine it responded me back

$ ping

64 bytes from icmp_req=1 ttl=64 time=0.105 ms
64 bytes from icmp_req=2 ttl=64 time=0.123 ms

while , searching on google, I come across ssh -v ip command, which tell information about ssh at given IP.

$ ssh -v #but it also end with connection refused error
ssh: connect to host port 22: Connection refused.

Some one suggested the possibility of duplicate Ip address on network. I doubt this, however to make this sure that two people are not assigned same IP by mistake on my network. I installed arp-scan. It is used to track all the assigned IP on your network

$ sudo apt-get install arp-scan
$ sudo su –
# arp-scan -I eth0 -l | grep # it will list all system using the IP    00:e0:4c:02:c1:ef    REALTEK SEMICONDUCTOR CORP.

So,my assumption is wrong as the arp-scan showing only one assigned IP. Still do not know the reason y the error is coming.I tried to ssh to my own system as below…which is getting connected

$ ssh -v
OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to [] port 22.
debug1: Connection established.

I looked, at my own system and my friend system and found that I have both ssh client and ssh server installed on my system but my friend system having only ssh client. I installed ssh server as below and it solved my problem

$sudo apt-get install openssh-server

So, This is the summary of things you should check if get connection refused error.

-> check that Internet is up on the system you are trying to ssh
-> check that ssh machine listing to default port 22. If not, say it listing to 3456, then while doing ssh pass the port option also as below
$ ssh suresh@ -p 3456
If you want to see other available options, type below command
$ssh –help #it will list all the available options for you
-> check that firball not blocking the connection
-> check that ssh-client and ssh server is installed on ssh machine. If not, install them as below, you can get detail here .

$sudo apt-get install openssh-client

$sudo apt-get install openssh-server


Author: arunyadav4u

over 7 years experience in web development with Ruby on Rails.Involved in all stage of development lifecycle : requirement gathering, planing, coding, deployment & Knowledge transfer. I can adept to any situation, mixup very easily with people & can be a great friend.

Leave a Reply

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

You are commenting using your 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