To type commands in a distant shell, you can use your peripherals (keyboard, monitor) or SSH. It is more comfortable to use SSH because you can use your usual terminal, with the right keymap, theme, etc.
For this project, you will need to add the VM 01_remote
Download VMs here: VM Downloads.
After downloading the archives, add the virtual machine to the system:
- Select on the menu bar:
Machine → Add. - Navigate to VM and select it.
Because the VM is behind the virtualization software router, you can't access it directly. Unless you add a port forwarding rule in the VM settings that maps a host port to a guest port. Host refers to your machine and guest to the VM.
Host & guest IP addresses don't need to be specified, guest port needs to be 22 because that's SSH default listening port.
Then connect to it via SSH (this is the only way since consoles are disabled):
ssh -p HOST_PORT root@localhost
It is recommended to change the default SSH port (22) to prevent bots from trying to connect to it. Since we are pretending that the guest VM is a server, change the SSH service port and make sure the port forwarding still works!
In addition, you will need to allow the new port in the firewall ufw.
-
Download the VM:
- Go to the provided link and download the
01_remoteVM.
- Go to the provided link and download the
-
Add the VM to VirtualBox:
- Select
Machine → Add. - Open the file
01_remote.vbox.
- Select
-
Add the VM to UTM:
- Open UTM.
- Select
Files → Open. - Navigate to
01_remote.utmand select it.
-
Open VM Settings:
- Select the
01_remoteVM and go toSettings.
- Select the
-
Configure Network:
- Go to the
Networktab. - Select
Adapter 1and ensure it is attached toNAT. - Click on
Advancedand thenPort Forwarding.
- Go to the
-
Add Port Forwarding Rule:
- Add a new rule with the following settings:
- Name: SSH
- Protocol: TCP
- Host Port: Choose an available port on your host machine (e.g., 2222).
- Guest Port: 22
- Add a new rule with the following settings:
- Open your terminal:
- Use the following command to connect to the VM via SSH:
ssh -p HOST_PORT root@localhost
- Replace
HOST_PORTwith the port you chose (e.g., 2222).
- Use the following command to connect to the VM via SSH:
-
Edit SSH Configuration:
-
Restart SSH Service:
- Restart the SSH service to apply the changes:
systemctl restart ssh
- Restart the SSH service to apply the changes:
-
Update Port Forwarding Rule:
- Go back to the port forwarding settings in VirtualBox or UTM.
- Update the
Guest Portto the new port number you set in the SSH configuration (e.g., 2222).
-
Allow New Port in Firewall:
- Allow the new port in the firewall:
ufw allow NEW_PORT
- Replace
NEW_PORTwith the new port number (e.g., 2222).
- Allow the new port in the firewall:
- Connect via SSH using the new port:
- Use the following command to connect to the VM via SSH with the new port:
ssh -p NEW_PORT root@localhost
- Replace
NEW_PORTwith the new port number (e.g., 2222).
- Use the following command to connect to the VM via SSH with the new port:
Maksym Kotkov / mkotkov



