SSH to Virtualbox VM from Host PC
Sometimes it’s really helpful if you can ssh to your local VM from the host OS. Most of online tutorials suggests to use port forwarding, but NAT networking does not work for me even though I don’t know exactly why. So I switched to bridge netowrking and finally it worked, here are the steps.
Make sure you’ve shutdown the VM, in the setting panel,
Adapter 1 ->
Attached to, select
Bridge Adapter, save the setting by clicking
Start your VM, type
ifconfig in the terminal and check your IP address.
Back to your host, type
ipconfig in the command line window (I assume that you are using Windows).
So host IP is
10.172.2.34 and VM IP is
10.172.2.39, they are in the same network.
Now you can type this from your host command line window.
If you get a “port 22: Connection refused error”, please check this post: Why am I getting a “port 22: Connection refused” error?. In short, install
openssh-server if you need it, start it, enable
ufw, or disable
Once sshd is working, you should be able to connect to your VM from the host PC.