You’ll not be able to directly access your guest virtual machine in Virtualbox via SSH or RDP if it’s under NAT network. For this you’ll have to configure port forwarding as detailed below;

  1. Go to Virtualbox‘s main interface and make sure the virtual machine that you want to configure is powered off.
  2. Select your virtual machine and click Settings icon on the top toolbar. Alternatively, right click on the virtual machine and click Settings.
  3. Click on the Network tab in Settings main interface.
  4. Look for and click on Advanced text at the bottom of the window.
  5. Click on Port Forwarding button.
  6. Click on the + icon on the upper right to add new port forwarding rule in Port Forwarding‘s main interface.
  7. Some of the fields are automatically filled up as the followings.
  8. Fill in the fields accordingly.

    In this example, port 2202 in the host machine will forward to port 22 of the guest machine whereby is the default IP for guest VM under NAT network.

  9. Test the forwarding rule.

    $ ssh -p2022  [email protected]
    Warning: Permanently added '[]:2022' (ECDSA) to the list of known hosts.
    [email protected]'s password:
    Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-83-generic x86_64)
     * Documentation:
     * Management:
     * Support:
    0 packages can be updated.
    0 updates are security updates.
    Last login: Fri Jul  7 09:29:30 2017
    [email protected]:~$

    SSH is used to test the forwarding rule as SSH is listening on port 22 of the guest VM.