-
Notifications
You must be signed in to change notification settings - Fork 122
VirtualBox specific Instructions
Perhaps the easiest way to ssh into a VirtualBox VM is to via a host-only network interface, as we suggest.
First, add a host-only network interface to your VM.
Next, boot your VM and make sure that this new interface has showed up as eth1:
ifconfig -a
To allow network access in the VM, execute:
sudo dhclient eth1
which grabs an IP address. If eth1 is a host-only network interface, you are all set and should be able to ssh to eth1's IP address from your host.
You can edit /etc/network/interfaces to add an entry for eth1, e.g.
auto eth1 iface eth1 inet dhcp
This will run dhclient automatically on eth1.
As an alternative to the host-only network, you can change the default, NAT interface as shown below and execute sudo dhclient eth0.
In order to log in via a NAT interface, we need to set up port forwarding. This may also enable users on your LAN to log in to the VM, which you may or may not want.
One way to set up port forwarding is to use the VirtualBox GUI.
To set up Port Forwarding using the GUI, select your VM and go to
Settings > Network > Adapter 1 > Advanced > Port Forwarding
and then add a rule to forward TCP host port 2222 to guest port 22.
It is also possible to set up port forwarding via the (OS X, Linux or Windows) command line, and this is described below.
OS X / Linux Users Run the VBoxManage commands below from a local terminal (not the VM window).
Windows Users If you are using Windows Vista, first close Virtual box, to ensure that config files aren't locked. Then open a command line prompt, by click on 'Start', then 'Run', then typing 'cmd' and hitting enter. In the terminal that appears, change to the VirtualBox directory:
cd "C:\Program Files\Sun\xVM VirtualBox"
All OSes: From a terminal on your local machine (NOT the VM/VirtualBox), run:
VBoxManage setextradata OpenFlowTutorial "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 2222 VBoxManage setextradata OpenFlowTutorial "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22 VBoxManage setextradata OpenFlowTutorial "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP
Verify the settings:
VBoxManage getextradata OpenFlowTutorial enumerate
The three values you added above should be shown.
Save your network settings for future reboots, by powering down the VM, from the VM window:
sudo poweroff
Restart the OpenFlowTutorial VM once again, by clicking 'Start' at the top of VirtualBox. Login again with the correct user name and password.
Windows Users You may need to change the VM configuration. Edit /etc/network/interfaces. Check that it says:
allow hot-plug eth1 iface eth1 inet dhcp
If it says eth0, change it to eth1; note that to write the file you'll need to use sudo. If you changed the interfaces file, poweroff the machine (sudo poweroff) and then start it again.
First, make sure you've set up port forwarding to forward host port 2222 to VM port 22, as described above. If you haven't set this up correctly, it will not work!
To SSH from the local machine to the VM, on the local machine run:
ssh -Y -l <user name> -p 2222 localhost
with the correct user name and password. Test the X11 forwarding by running on the local machine:
xterm
and a new terminal window should appear. If you have succeeded, you are done with the basic setup. Close the xterm.
Start Xming; nothing exciting will happen but it will show an icon on the right of the toolbar.
Open a terminal: click 'Start', 'run', then enter 'cmd'.
Change to the directory where you saved putty.
cd <dir>
Run:
putty.exe -X -P 2222 -l <user name> localhost
A new window will pop up; type in the password. Now, type:
xterm
A white terminal window should appear. If you have succeeded, you are done with the basic setup. Close the xterm.
Make sure you use the correct user name and password for your VM image.
OpenFlow Tutorial Wiki - please feel free to fix errors and add improvements!