Ubuntu Setup Note

SSh Into Ubuntu VM Virtualbox

Method 1. Port forwarding from GUI

For the guest VM, then open “Settings” >> “Network” >> “Advanced” section.

Click on “Port Forwarding” button, add a new port forwarding rule.

For example, set up the rule from the panel as

To confirm that port 2522 is listening, we check using the netstat command.

Now, we can SSH to the guest VM using

ssh -p 2522 <login>@127.0.0.1

Here, the SSH login request sent to 127.0.0.1:2522 will automatically be translated into 10.0.2.15:22 by VirtualBox. Thus, we can now SSH to the guest VM.


Method 2. Port forwarding from command line

To create a port forwarding rule for guest VM named “Centos” with IP address 10.0.2.15 and SSH port 22, mapped to local host at port 2522, use the command:

VBoxManage modifyvm "Centos" --natpf1

"SSH,tcp,127.0.0.1,2522,10.0.2.15,22"

Here, the name of the rule should be set as unique.

After creating the rule, we verify it using

VBoxManage showvminfo "Centos" | grep NIC

And, this will show the rule in the results.

================================================================================

Install SSh on Ubuntu

Let's start to install openssh-server.
First update the system

$ sudo apt update

$ sudo apt upgrade

To install openssh-server package, run:

$ sudo apt install openssh-server

Once installed, the SSH service should be started automatically. If necessary, you can start (or stop, restart) the service manually via command:

$ sudo service ssh start

Verify that ssh service running

$ sudo systemctl status ssh

Configure firewall and open port 22

Before enabling the UFW firewall we need to add a rule which will allow incoming SSH connections. If you’re connecting to your server from a remote location, which is almost always the case and you enable the UFW firewall before explicitly allow incoming SSH connections you will no longer be able to connect to your Ubuntu server.

To configure your UFW firewall to allow incoming SSH connections, type the following command:

$ sudo ufw allow ssh

Now we can enable UFW firewall by typing:

$ sudo ufw enable

You can check the status of UFW with the following command:

$ sudo ufw status

================================================================================

Install VS Code on Ubuntu

sudo snap install –classic code

================================================================================

End