Skip to content

mkotkov/remote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

remote

Remote Connect Project

Introduction

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.

Links

  • For X86-64 chips, use VirtualBox Download
  • For Apple Silicon chips, use UTM Download (for iOS)

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

Configuration

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.

Instructions

Step 1: Add the VM

  1. Download the VM:

    • Go to the provided link and download the 01_remote VM.
  2. Add the VM to VirtualBox:

    • Select Machine → Add.
    • Open the file 01_remote.vbox.
  3. Add the VM to UTM:

    • Open UTM.
    • Select Files → Open.
    • Navigate to 01_remote.utm and select it.

Step 2: Set Up Port Forwarding

  1. Open VM Settings:

    • Select the 01_remote VM and go to Settings.
  2. Configure Network:

    • Go to the Network tab.
    • Select Adapter 1 and ensure it is attached to NAT.
    • Click on Advanced and then Port Forwarding.
  3. 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

alt text

Step 3: Connect via SSH

  1. Open your terminal:
    • Use the following command to connect to the VM via SSH:
      ssh -p HOST_PORT root@localhost
    • Replace HOST_PORT with the port you chose (e.g., 2222).

alt text

Step 4: Change SSH Port

  1. Edit SSH Configuration:

    • Open the SSH configuration file on the VM:
      nano /etc/ssh/sshd_config
    • Change the line #Port 22 to a new port number (e.g., Port 2222). alt text
  2. Restart SSH Service:

    • Restart the SSH service to apply the changes:
      systemctl restart ssh
  3. Update Port Forwarding Rule:

    • Go back to the port forwarding settings in VirtualBox or UTM.
    • Update the Guest Port to the new port number you set in the SSH configuration (e.g., 2222).
  4. Allow New Port in Firewall:

    • Allow the new port in the firewall:
      ufw allow NEW_PORT
    • Replace NEW_PORT with the new port number (e.g., 2222).

    alt text

Step 5: Verify Connection

  1. 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_PORT with the new port number (e.g., 2222).

Author

Maksym Kotkov / mkotkov

About

Instructions for connecting to a virtual machine via SSH

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published