[SOLVED] can't ssh from host to guest...

Discussions related to using VirtualBox on Linux hosts.
Post Reply
masavini
Posts: 15
Joined: 3. Sep 2013, 21:55

[SOLVED] can't ssh from host to guest...

Post by masavini »

hi,
i've just upgraded my server to ubuntu 14.04: everything works fine except for ssh connection from host to guest.

my settings:

Code: Select all

teo@host $ ifconfig
eth1      Link encap:Ethernet  HWaddr 20:cf:30:19:b5:ce  
          inet addr:192.168.1.4  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::22cf:30ff:fe19:b5ce/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1143689 errors:0 dropped:7 overruns:0 frame:0
          TX packets:2359406 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:374159339 (374.1 MB)  TX bytes:3129572826 (3.1 GB)

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:65536  Metric:1
          RX packets:17390 errors:0 dropped:0 overruns:0 frame:0
          TX packets:17390 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:2047225 (2.0 MB)  TX bytes:2047225 (2.0 MB)
vboxnet0  Link encap:Ethernet  HWaddr 0a:00:27:00:00:00  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::800:27ff:fe00:0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9898 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:1064885 (1.0 MB)

Code: Select all

teo@guest $ ifconfig
eth1      Link encap:Ethernet  HWaddr 08:00:27:b6:8f:39  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feb6:8f39/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1824 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1556 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:282358 (282.3 KB)  TX bytes:197473 (197.4 KB)
          Interrupt:19 Base address:0xd020 

eth2      Link encap:Ethernet  HWaddr 08:00:27:af:47:58  
          inet addr:192.168.56.101  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:feaf:4758/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:113 errors:0 dropped:0 overruns:0 frame:0
          TX packets:39 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:17206 (17.2 KB)  TX bytes:5540 (5.5 KB)
          Interrupt:16 Base address:0xd240 

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:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:240 (240.0 B)  TX bytes:240 (240.0 B)
ssh from guest to host works fine, but if i try to connect from host to guest i'm first asked if i really want to add the RSA to the list of known hosts, then i get connected to the host itself:

Code: Select all

teo@host $ ssh 192.168.56.101
The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established.
RSA key fingerprint is bla:bla:bla.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.56.101' (RSA) to the list of known hosts.
teo@host $
if i remove 192.168.56.101 from known_hosts, nothing changes...

how can it be?! any suggestion..?
Last edited by masavini on 9. May 2014, 13:39, edited 1 time in total.
smithlar
Posts: 79
Joined: 9. May 2008, 15:54
Primary OS: openSUSE
VBox Version: PUEL
Guest OSses: WinXP32 WinXP64 Win7-32 Win7-64 openSUSE64 OS2 Win10
Location: Texas, USA

Re: can't ssh from host to guest...

Post by smithlar »

It appears that your guest is using NAT rather than Bridged as
its network mode. You can't come into a NAT, you can only
go out. (unless you also use port forwarding on the Host).

Just set your Guest to use Bridged networking in the VM's settings
and let the Guest get its own 192.... IP address from the router or
DHCP server. With Bridged, the Guest can initiate outbound
connections and the Host (and others) can initiate inbound connections.
masavini
Posts: 15
Joined: 3. Sep 2013, 21:55

Re: can't ssh from host to guest...

Post by masavini »

i've already tried with the bridged adapter, but the vm won't start anymore... this is the errore i get:

Code: Select all

Failed to open a session for the virtual machine guest.
Unknown configuration node '//ssh' found in the configuration of IntNet instance #0 (VERR_CFGM_CONFIG_UNKNOWN_NODE).
> Details
Result Code: 
NS_ERROR_FAILURE (0x80004005)
Component: 
Console
Interface: 
IConsole {8ab7c520-2442-4b66-8d74-4ff1e195d2b6}
is port forwarding the only option i have? i'm not that expert in configuring ports...
masavini
Posts: 15
Joined: 3. Sep 2013, 21:55

Re: can't ssh from host to guest...

Post by masavini »

i've finally solved with port forwarding: less pain than expected...

just added a port forwarding rule in the guest network card settings, so that connections to the host port 2222 are forwarded to guest port 22.
then i created the file ~/.ssh/config:

Code: Select all

Host guest
HostName 192.168.56.101
Port 2222
now i can simply connect from host to guest with the command

Code: Select all

ssh guest
thanks for your support!
Post Reply