Skip to main content

ELL Blog

How to SSH Into VirtualBox

For the Oracle VirtualBox VM, click the virtualbox network settings and add a new port forwarding rule under advanced settings and add a rule for SSH with the TCP protocol, 3022 Host port, and 22 guest port.

port forwarding UI in VirtualBox

On the Virtual Machine, install openssh-server. This is how you would do it on Debian-based systems. I’m using Linux mint.

sudo apt install -y openssh-server

On your own machine, first try sshing into the virtual machine.

ssh -p 3022 elijah@

Once you can confirm it works, we want to copy our ssh-id so that we won’t have to repeatedly use our passwords. Especially when we want to use VSCode or something.

Password-less SSH

If you do not have an SSH key, ssh-keygen -t ed25519

If you’re on Windows, you will need to first install the OpenSSH feature from Settings or you can use WSL to be able to use ssh-keygen.


Use either of the two commands below to copy your SSH ID to the Virtual Machine’s authorized keys. I created an SSH key on my PC over 4 years which is why when at the time the “gurus” were all spouting RSA.

type ~\.ssh\ | ssh -p 3022 elijah@ "cat >> .ssh/authorized_keys"
type ~\.ssh\ | ssh -p 3022 elijah@ "cat >> .ssh/authorized_keys"


ssh-copy-id -p elijah@

To integrate with VSCode, adapt the following into your .ssh/config file

Host "VirtualBox Linux Mint"
    User elijah
    Port 3022
    IdentityFile "C:\Users\maste\.ssh\id_rsa"

If you want to run a GUI on the VirtualBox, run export DISPLAY=:0 first