Install SSH Into a VirtualBox Ubuntu Server
sudo apt install openssh-server
sudo systemctl status ssh
Right-click on the VM you want to SSH into and click the Setting cog to open the settings window. Alternatively, you can also use the keyboard shortcut: Ctrl + S. Next, click on the Network option. Click on the Advanced option and select Port Forwarding. VirtualBox will present you with a screen to configure your port forwarding rules.
Click on the Plus (+) icon under the Port Forwarding Rules page.
Give your rule a meaningful name (for example "SSH port forwarding"). Use the default protocol i.e. TCP. The host IP will be 127.0.0.1 or simply localhost and use 2222 as the Host Port.
Get the IP address of your Ubuntu server running inside VirtualBox and enter it in the Guest IP input box. In this case, my guest OS IP address is 10.0.2.13. Use 22 as the guest port.
Finally, press the OK button.
From the terminal in your main operating system, run the SSH command in the following format: ssh -p 2222 [email protected]. For example:
ssh -p 2222 [email protected]
Thanks for reading 📖.