My friend has a windows laptop and has installed a Linux VM using virtual box I want to ssh into the Linux vm using my Mac OS and we are connected to the same wi-fi network (the network adapter is NAT).

What I did -

  1. Start the ssh server into the linux VM.
  2. Set up port forwarding in VM settings
  3. I achieved this by adding (source IP -, src port - 9998, dest-ip =, dest port = 22)
  4. Then I went to my router settings (I have a D-Link DIR 615 router, I couldn't see port forwarding (have firmware 20.07) and went to virtual server and added a couple of rules (I don't know how was I supposed to do that).

I am able to ssh into his vm from his laptop (added the rule of loopback address), but am not able to do this from my laptop.

I am able to ssh from my laptop to other machines, but not any vm's.

  • Did you adjust the firewall on your host machine (your friend’s bare metal machine) to allow incoming traffic to port 9998? [You don’t need to change any rules on the router if you are on the same network (for a typical home network).] How are you trying to reach the VM—from the config you describe, you’ll need to ssh to
    – Calchas
    Sep 25 '18 at 16:11

You will need an IP address on the virtual machine that is visible on the network. Probably the easiest way is to add a new network interface to your virtual machine of the correct type. There are a few possibilities.

  1. If you are trying to access a virtual machine from that machine's host, you can use what is called a host-only adapter. First you'll have to create a network interface under the Host Network Manager section of virtualbox, then you can attach a network interface in the machine's settings to use that host-only adapter. The host will provide a DCHP address for the virtual machine's network interface. Then you can use ssh to get into the VM using the address.

  2. If you want to access the virtual machine from any machine on the network, then you will need a bridged adapter on the virtual machine. This adapter will reach out to the external network to ask for a DHCP address. Once you find this IP address it can be used with ssh from any machine on the network.

If you need the address to always be the same then you will have to set up the interface (either the host-only network adapter or the bridged adapter) to use a fixed address instead of DHCP. This configuration will have to be done in the guest OS, not the VM settings.

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.