Search code examples
sshvisual-studio-codevirtual-machinevirtualbox

Connecting Visual Studio Code (VSCode) to VirtualBox VM


I've been using WSL to debug C in VSCode, using Ubuntu from the Windows Store.

However, because my school projects must be able to run on a provided Virtual Machine (Lubuntu, in this case), it would be of great help if I could debug my code on Windows, through a connection to the Virtual Machine.

I've failed to find any good tutorials on this, so I tried playing around with the ip addr show command and connecting to the resulting address using ssh, but to no avail.

What would be the best approach to achieve this?


Solution

  • Found the solution. In the VM settings, I needed to add a Network Host-only Adapter. From there, I installed openssh-server in my VM:

    sudo apt-get install openssh-server openssh-client
    

    Then, by calling ifconfig I got my VM's ip (enp0s8 interface) and connected to it via ssh.

    Hopefully this helps anyone facing the same issue.