This guide walks you through setting up a virtual machine (VM) on Windows, configuring SSH access, and connecting to it using VS Code. By the end, you'll have a functional VM server that's ready for development.
Before starting, ensure you have the following:
- A Windows machine with virtualization enabled.
- A hypervisor installed, such as:
- VirtualBox (used in this guide).
- Hyper-V (optional alternative for Windows Pro/Enterprise users).
- Windows Subsystem for Linux (WSL) installed (required only if using VirtualBox alongside WSL).
- VS Code installed on your Windows machine.
- Download the VirtualBox installer from the official VirtualBox website.
- Run the installer and follow the on-screen instructions to complete the installation.
-
Download a Linux distribution ISO (e.g., Ubuntu Server) for your VM.
- Download Ubuntu Server here.
- Example of the VirtualBox home screen:

-
Open VirtualBox, click New, and follow the prompts to create your VM.

-
Set the VM name to something memorable (e.g.,
UbuntuDev) and select the downloaded ISO. -
When prompted, create a password that’s easy to remember.
-
Allocate resources:
-
Create a virtual hard disk:
-
Click Finish and boot the machine. You should see the following screen:

-
Press Enter to continue.
-
Follow the on-screen prompts by pressing Enter at each step:
-
Storage setup: Press Done and Continue on the storage configuration screen.

-
Set up the server profile:
-
Ensure Install OpenSSH Server is selected before continuing.

-
Skip additional featured server snaps and wait for the system to install.


-
Once installation is complete, shut down the VM.
-
Configure Port Forwarding to enable SSH access from the host machine to the VM:
-
Boot the VM. You can run it normally or in Headless Mode for efficiency.
-
Open Command Prompt (cmd) or a terminal on the host machine.
-
Use SSH to log in to the VM with the following command:
ssh -p 2222 [email protected]
Replace
usernamewith the username you created during the VM setup.

-
If prompted, accept the SSH key fingerprint by typing
yes. -
Once logged in, you have successfully connected to the VM using OpenSSH. Here’s an improved version of Step 5:
-
Locate your
id_rsa.pubfile (usually found inC:/Users/YourUsername/.sshon Windows).-
If it doesn’t exist, generate a new RSA key pair with the following command:
ssh-keygen -t rsa
-
-
Copy the contents of
id_rsa.pubto your clipboard.-
On Windows, you can use:
clip < ~/.ssh/id_rsa.pub
-
-
Log in to your Ubuntu server (using your password).
-
Open or create the
authorized_keysfile in your server's.sshdirectory:nano ~/.ssh/authorized_keys -
Paste the contents of your
id_rsa.pubinto the file. -
Save and exit the editor (
Ctrl+O,Enter, thenCtrl+Xin Nano). -
Verify that the key works:
-
Exit the server with:
exit -
Reconnect using SSH:
ssh -i ~/.ssh/id_rsa <username>@<server-ip> -p <port>
-
-
If you’re not prompted for a password, the RSA key setup was successful!
-
If it still requests a password, recheck the permissions of your
.sshdirectory andauthorized_keysfile:chmod 700 ~/.ssh chmod 600 ~/.ssh/authorized_keys
-













