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.
sshd runs at port 22 (checked)
firewall disable(checked)
network: ping is ok (checked)
ssh localhost is ok (checked)
However, I can't ssh this host from another machine.
Best Answer
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:
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?