This would be a very short post on how to ssh into your guest OS from your host OS in virtualbox.
Though there are other ways in which you could access your guess OS from your host, I found the Port Forwarding method to be extremely easy to implement.
Note: I assume that you have installed an operating system in virtualbox and that openssh-server is installed in it
and the steps are,
- Click on Settings in your virtualbox manager
- Click on Network
- Assuming that the default network type is NAT, click on Port Forwarding
- On the Port Forwarding Rules window, create a new rule by clicking on Add new port forwarding rule
- Fill the table with following details that are necessary and rest can be left blank,
- Protocol – TCP (filled by default)
- Host port – . Ex: 3000 (make sure its not being used elsewhere)
- Guest port – 22 (since ssh runs on port 22)
- Click Ok on both Port Forwarding Rules and Network window
Note: You need not restart your VM and this can be done before you start or after you have started your guest OS
To test if you are able to ssh into your guest OS, make sure its up and running. Then from your host OS terminal type in the following,
ssh -p @127.0.0.1
Ex: ssh -p 3000 email@example.com
and that’s it. You can now ssh into your guest OS. I found this from a stackoverflow post which made me to write this post.
I know what y’all thinking, “Picture is worth a thousand words”. Here you go !
Step 1: Click on Settings
Step 2: Select Network
Step 3: Add a new rule and Ok it
Step 4: Left window shows terminal from my host OS Linux Mint where I ssh into my guest OS Trisquel running in a virtualbox to the right
I basically write this post for others who wanted to try this and as a way for myself to remember what I have learned and to be reminded if I forget it 🙂 🙂