Short version

If I am running an Ubuntu guest VirtualBox VM from a Windows 10 host, what steps do I need to take to ssh from a remote linux server into the Ubuntu guest VM?

[                     ]
[ Windows 10          ]
[ ___________________ ]            ____________________
[ [                  ]]            [                   ]
[ [ Ubuntu VM (guest) <----HOW?---- SUSE remote server ]
[ [__________________]]            [___________________]

Long version

I am confused because, AFAIK if I wasn't using an Ubuntu guest VM, and was instead using a real Ubuntu machine, I could just cat /etc/hosts, find the IP address of local and then from remote just:

user@remote --ssh--> user@<local IP>

I already setup the ssh keys so that I can ssh from the Ubuntu guest into the SUSE remote server (i.e. the guest ~/.ssh/id_rsa.pub is already stored in the remote ~/.ssh/authorized_keys). I.e. I can already:

ssh -Y user@remote

Without difficulty, but I cannot do it the other way round simply because I have no idea what my guest's IP address is. And I already tried ssh-ing with the IP addresses in "Connection Information" from the Ubuntu GUI.

Also to be clear:

  • guest VM is Ubuntu 12.04 LTS (64-bit)

  • VirtualBox settings mostly: default

  • Enable Network Adapter: NAT (cable connected, no port forwarding)

I have not set up an ssh server, but I am not sure it's necessary (?), this is my understanding so far.

So, given that I am running an Ubuntu guest VirtualBox VM from a Windows 10 host, what steps do I need to take to ssh from a remote linux server into the Ubuntu guest VM?

migrated from askubuntu.com Feb 15 '17 at 14:57

This question came from our site for Ubuntu users and developers.


This is usually called a "double NAT" situation when you're behind a router. You have to forward from the border router to the Windows system, and then forward in VBox to the VM. You might also have to forward port 22 from the actual network connection to the VBox NAT adapter, but I'm not as clear on that for Windows.

Ultimately, though, there's at most three things you'll have to do here. They're all in Windows, or not in Ubuntu Linux, so most of your answers will be on Super User or elsewhere.

  1. (If you are behind a router on your network that Win10 is on) Set up Port Forwarding on your router on the network to forward Port 22 to your Windows 10 system.

  2. Set Windows Firewall to allow connections inbound on Port 22. You may also need to specify that you want Port 22 to be forwarded from your inbound network adapter to the NAT network on the VM network settings.

  3. Set the NAT forwarding rule on the NAT network in VirtualBox to forward Port 22 on the host to Port 22 on the VM.

A slightly more nicer approach that sort of bypasses Step 2 and Step 3 here is to use Bridged Mode in the VM network settings; this will then get an IP from the same network as the Windows 10 system is connected to, and you can then port forward port 22 at the edge router (step #1) to the IP assigned by the network to the VM itself. This is a little less painful than having to do multiple hops and configurations to get Port 22 working.

NOTE: Some ISPs filter Port 22 so Port 22 traffic won't reach the system; you may have to set up a higher port than Port 22 (such as 2022 or another nonstandard port >1024) instead if this is the case.

As for finding the guest's IP, that info will be in the output of ifconfig -a or ip -4 addr list in the Linux guest. That's the easiest part out of all of this, because this will be the same, Bridged or NAT.

  • I will research this thanks, I really do not know how you answered so quickly... Will delete this comment after researching – hello_there_andy Feb 15 '17 at 15:09
  • 1
    @hello_there_andy I do a lot of virtualization on my laptop, either through Linux-based LXC/LXD containers on a NAT setup, or through VMware, with similar evils to NAT (basically, I'm used to this set of issues heh). The process is similar in Linux and Windows, but completely different in terms of steps, though in my cases my VMs don't ever need outside -> in; for those VMs, I put them on a dedicated ESXi hypervisor that is a machine dedicated to run VMs, and bridge it direct to an existing Ethernet setup (no NAT there heh). But that's an atypical setup, of course. – Thomas Ward Feb 15 '17 at 15:11
  • 1
    @hello_there_andy just make sure the guest has openssh-server installed on it as well - so you can accept SSH. Outside of that, the rest is Windows networking/firewall/configuration stuff. (Hence, Super User and not Ask Ubuntu) – Thomas Ward Feb 15 '17 at 15:12

You'll need to set port forwarding in Windows 10 VM player

You'll need to set external port on Windows 10 machine, which will be forward to the service port on the virtual machine in the NAT network.

This link explain how to do it

  • 1
    While this may theoretically answer the question, link only answers are generally frowned upon. It would be preferred for you to include relevant information from linked posts, in case such posts go away at some point in the future. – Thomas Ward Feb 15 '17 at 14:45
  • Thanks for the comment, and for providing the details in your answer. – Yaron Feb 15 '17 at 14:53

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.