2010 Jan 22

I use Fedora for RTEMS development and Ubuntu for my regular academic, leisure tasks. Fedora 12 is a Qemu image which I run using the linux kvm module. It never struck me until recently to just ssh into the guest machine (Fedora 12) from the host (Ubuntu 9.10) and do my RTEMS development work. I had always started the VM and worked inside it. This made my other applications on my host (Ubuntu 9.10) crawl. By default, both KVM as well as Virtual Box have guest to host communication enabled. On the contrary, the host system cannot communicate with your guests. This can be done by making the guest (your Virtual Machines) to listen to one of the host system’s ports.

In KVM this is achieved by adding the “redir” argument to the command while starting the virtual machine;

kvm -hda fedora.img -hdb swap.img -boot c -m <memory allocation in megabytes> -redir tcp:[host-port]::[guest-port]

Here we would like to make the guest port 22 (default ssh port) listen on some host port, say 2222.

kvm -hda fedora.img -hdb swap.img -boot c -m 384 -redir tcp:2222::22

If you are using Virtual Box then follow this tutorial.

Now your guest machine can be accessed via ssh from your host system as you would do for any remote server. E.g.,

ssh -l rtems -p 2222 localhost

In case you need X forwarding, use the -X flag or the -XC flag for X forwarding with compression enabled.

Emacs with tramp mode on my (host) Ubuntu machine is all I now need. A perfect Fedora 12 “remote” development server is setup. I can now do away with all the jazz of GNOME/KDE on the virtual image ;) .

 

4 comments posted

Add your comment
  1. Can VirtualBox run an OS in the background without an active window (headless)? Use would be for a linux server that doesn’t use X, then we could just ssh into it.

  2. DarwinSurvivor Use Virt Manager / libvirt. By default it starts everything headless and exports console/X11 over vnc. Their “headfull” viewer is just a customised vnc viewer with shutdown, restart buttons =)

    Benefit is that you also get overview of all virtual machines they can be local, remote and use qemu/kvm/whatever

  3. When using VirtualBox, whichever networking mode you select for your VMs you can access them from your host. So your phrase “On the contrary, the host system cannot communicate with your guests.” is false.

    I have some QNX VMs in VirtualBox configured with Host Only or NAT networking modes and I don’t have a problem SSH-ing into them.

  4. Thanks folks for your comments.
    @Radu – Interesting, I will have a look at it. Thanks for the pointer.

© 2006-2009 Aanjhan Ranganathan, All rights reserved (unless otherwise stated).
Home Projects Presentations Profile Photography Notes Archives Blogroll Top ↑ Theme by Eficacy Designs