Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On my laptop I'm running two Ubuntu servers as guests on virtualbox. They are connected via a host-only adapter that has an IP address of '192.168.56.1', with the two guest severs having IP addresses set to '192.168.56.101' & '192.168.56.102'. Each one is able to ping the other but not ssh into it. When I try to ssh to the other guest, I'm given the following error:

ssh: connection to host 192.168.56.102 port 22: Connection refused

The confusing thing (to me anyway) is that I can ssh in the host-only adapter on the host laptop by using:

ssh user@192.168.56.1

I'm not sure of what to try next. I tried reinstalling ssh/sshd. That just gave me a whole mess of errors, but I'm thinking that if I can ssh one thing on the network on the network I should be able to ssh onto something else right? But anyway I'm definitely overlooking something.

I've tried to disable the iptables on the guests and host using

   sudo ufw disable

Then the used on one of the guests

   ssh user@192.168.56.102

and got

   ssh: connect to host 192.268.56.101 port 22: Connection refused

<-update->

ssh -v user@192.168.56.101

Is giving me the following output:

OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL1.0.1 14 Mar 1012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.56.101 [192.268.56.101] port 22.
debug1: connect to address 192.168.56.101 port 22: Connection refused
ssh: connect to host 192.168.56.101 port 22: Connection refused

<-update->

My /etc/hosts file looks like on all guests:

127.0.0.1    localhost
127.0.1.1    ubuntu

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

The two guest boxes do not have an /etc/hosts.allow & /etc/hosts.deny files.

ifconfig -a gives me:

eth0      Link encap:Ethernet  HWaddr 08:00:27:63:c5:71  
          inet addr:192.168.56.102  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fe63:c571/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:15 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4658 (4.6 KB)  TX bytes:1790 (1.7 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

and

eth0      Link encap:Ethernet  HWaddr 08:00:27:ce:7c:1e  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fece:7c1e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:15 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:4718 (4.7 KB)  TX bytes:1790 (1.7 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1184 (1.1 KB)  TX bytes:1184 (1.1 KB)

<-update->

sudo netstat -pant |grep :22

Gives no output

<-update->

Also when I try to get a box too SSH its self I get the same port 22: Connection refused error.

share|improve this question
    
What does netstat -pant |grep :22 say when you run it on the two guest machines? –  cjc Aug 1 '12 at 16:52
    
If there's nothing listening on port 22 then I am pretty sure you havn't got SSH installed, try running the "sudo apt-get install openssh-server" command, you may well have installed the client thinking it was the server. –  Alex Berry Aug 2 '12 at 13:45
    
Alex that was it. Thanks –  Paddy Aug 2 '12 at 15:24
add comment

4 Answers

Due to the fact you're getting a rejected message I can assume you're actually seeing packets hitting the other server, I suspect ssh is not installed.

On both servers run:

sudo apt-get install openssh-server

Once the ssh server is installed it should work fine.

<-- Edit -->

I have seen that you've confirmed the service is installed so ignore the above, it may well be iptables, though it shouldn't be configured by default on Ubuntu. If you're running 12.04 you can temporarily disable the firewall by typing:

sudo ufw disable

See if that helps at all.

Also, by "whole mess of errors" what do you mean? did you try to install with or without sudo?

share|improve this answer
    
Thanks But still getting 'ssh: connection to host 192.168.56.102 port 22: Connection refused' –  Paddy Aug 1 '12 at 16:21
1  
What exactly have you tried? I posted several options, the more detail the better. Please update your original post with the exact commands you try and the exact output, it's far easier to diagnose this way. Also, if you havn't yet run the first command then please do so, word for word, if it's already installed it will tell you so, if not then it will install it. –  Alex Berry Aug 1 '12 at 16:22
add comment

Try to use the ssh -v ip address , so you can see what could be wrong during the connection!

<<-- EDIT -->>
use this command on the host 101 and post the resutl

sudo netstat -plant | grep ssh


basically this command show all the network connections on your machine and I want to see if ssh run on a different port respect to 22

share|improve this answer
add comment

Are you sure you do not have a proxy command or something similar in your ssh_config file?

By looking at your output, there is a problem with the IP address in your debug output and in the error message: instead of 192.168.xxx.xxx, you have 192.*2*68.xxx.xxx

You should check your network configuration:

  • what is the output of the "ifconfig -a" command on each host?
  • can you check your /etc/hosts file?
  • can you check if there is something in your /etc/hosts.allow and /etc/hosts.deny files
  • ... and of course, as suggested, you may turn off iptables
share|improve this answer
    
Ah sorry the '*2*68' was a typo I'll try your suggestions. –  Paddy Aug 2 '12 at 8:55
add comment

I believe that the "host-only" option creates a dedicated link between the guest and the server and VMs using host-only connections should not be able to see each other on the network.

You'll either have to bridge them in linux or use another network option.

I believe that what you are trying to achieve can be done if you change the network option of both VMs to "Internal Network" and use the same name for both VMs.

Edit: The according to the virtualbox documentation the "host-only" option should allow the VMs to communicate with each other but still - give it a try.

Edit2: Oh - I kinda missed the fact that the machines are able to ping each-other. In this case what I have written above is irrelevant.

share|improve this answer
    
I'm getting the same thing can ping but not ssh "ssh: connection to host 192.168.10.2 port 22: Connection refused" note the ip address is changed by the Internal Network. Also "use the same name for both VMs" is this both servers should be named "ubuntu@ubuntu"? –  Paddy Aug 2 '12 at 10:58
    
When you choose "Internal Network" for a network adapter in Virtualbox you get to select the name of the Internal Network. The two VMs will not see each other unless you have selected the same name for the "Internal Network" –  user1569051 Aug 2 '12 at 11:37
    
yes that is what I did. –  Paddy Aug 2 '12 at 11:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.