How to SSH Into a VirtualBox Ubuntu Server

--Reference --

Installing SSH on the Virtual Machine


        Install SSH
        $ sudo apt install openssh-server

        To check status of ssh
        $ sudo systemctl status ssh

Configuring the VirtualBox Network


        Get IP of virtualbox (eg:10.2.2.2)
        $ ifconfig
        
        Goto to Network settings of Guest os
        Creates a Network Address Translation (NAT) adapter
        Add port forwarding
            -> protocol : TCP 
            -> Host Ip  : 127.0.0.1
            -> Host Port: 2222
            -> Guest IP : give ip of virtualbox 
            -> Guest port : 22

Start Your SSH Session


        Connect to SSH
        $ ssh -p 2222 user_name@127.0.0.1