1

I'm running an instance of Ubuntu Server 14.04 inside VirtualBox, and for multiple reasons, I prefer to work with it using the terminal emulator on the host system (OS X 10.0) than with the default 800x600 terminal from the VM's VGA output.

Currently I have the VM accessing the internet over a bridged adapter so that it appears on the local network. Then, I connect to it over SSH. This setup is of course quite problematic, mainly because I have to actually be connected to a stable local network for this to work, and I have to broadcast the VM to everyone else on the network.

I'm sure there has to be a better way, but I have no idea what it is. Ideally I'd have the VM connecting to the internet through NAT only, and wouldn't need an internet connection to use the setup.

  • 1
    You could add a second host-only interface to your vm and use this for host-vm-communication. – Jodka Lemon Sep 8 '15 at 1:51
  • @Jodka Could you elaborate on exactly what interface I would use, and what protocol I would use to attach the terminal? – lcmylin Sep 9 '15 at 4:08
0

You should be able to forward a port on localhost to the VM.

I don't know how to do it in VirtualBox, but on Qemu it is a command option:

qemu-kvm [all your usual qemu options] -net nic -net user -redir tcp:22122::22

Then ssh into it:

ssh -p22122 klaatu@localhost

I imagine that VirtualBox has a similar function in its GUI settings panel.

  • I tried using port forwarding, but after the ssh command I just get Connection refused. If I enable SSH on the host the connection isn't refused, it just goes to the host instead of the guest. – lcmylin Sep 8 '15 at 1:46
  • 1
    Nevermind. Forwarding to port 22122 worked. Must just have been the port I was forwarding too. – lcmylin Sep 8 '15 at 1:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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