Blog

Dec 21, 2024

Dev
Self Host

How to Install Ubuntu on a Fresh PC Using a USB Stick and Set Up Remote SSH Access

This guide includes steps for connecting your PC to Wi-Fi and enabling SSH access for remote users. Initially made for my friend, but if anyone else finds it useful, so be it.

Originally created for my friend Vibhor. If someone stumbles across this and finds it useful, cheers!

This guide will walk you through the steps to install the latest version of Ubuntu on a new PC using a USB stick, connect to Wi-Fi, and enable SSH access for remote users.

What You'll Need

  • A USB stick (at least 8 GB)
  • A working computer to create the bootable USB
  • An internet connection
  • The target PC for installation

Steps to Install Ubuntu

1. Download Ubuntu

  1. Visit the official Ubuntu website
  2. Click "Download Ubuntu Desktop" and select the latest version
  3. Save the .iso file to your computer

2. Create a Bootable USB

  1. Insert the USB stick into your working computer

  2. Use one of the following tools to create a bootable USB:

  3. Steps for Creating the USB:

    • Using Rufus (Windows):
      1. Open Rufus and select your USB device
      2. Click "Select" and choose the Ubuntu .iso file
      3. Use default settings and click "Start"
    • Using balenaEtcher (macOS/Linux):
      1. Open Etcher, select the Ubuntu .iso, choose the USB stick, and click "Flash"
  4. Wait for the process to complete and safely eject the USB

3. Boot the Target PC from USB

  1. Insert the bootable USB stick into the target PC

  2. Power on the PC and enter the BIOS/UEFI settings:

    • Typically accessed by pressing F2, F12, DEL, or ESC during startup
    • Refer to your PC's manual if unsure
  3. Set the USB as the Boot Device:

    • Navigate to the "Boot Order" or "Boot Options" menu
    • Move the USB stick to the top of the boot priority list
    • Save changes and exit
  4. Restart the PC, and it will boot from the USB stick

4. Start Ubuntu Installation

  1. After booting, you'll see the Ubuntu boot menu
  2. Select "Try or Install Ubuntu" and press Enter

5. Connect to Wi-Fi

  1. On the Ubuntu installer screen, click the Wi-Fi icon in the top-right corner
  2. Select your Wi-Fi network from the list
  3. Enter the password and click "Connect"
  4. Ensure the PC is connected to the internet before proceeding

6. Install Ubuntu

  1. Language Selection: Choose your preferred language and click "Install Ubuntu"
  2. Keyboard Layout: Select your keyboard layout and click "Continue"
  3. Updates and Software:
    • Choose to install updates and third-party software (recommended)
    • Click "Continue"
  4. Installation Type:
    • For a fresh PC, select "Erase disk and install Ubuntu"
    • For advanced users, choose "Something else" to customize partitions
  5. Confirm Changes: Review the partition setup and click "Install Now". Confirm if prompted
  6. Set Your Time Zone: Select your region on the map
  7. Create a User Account:
    • Enter your name, computer name, username, and password
    • Choose whether to log in automatically or require a password
  8. Installation: Wait for the installation to complete (10–20 minutes)
  9. Restart: Remove the USB stick when prompted and press Enter to restart

Post-Installation Setup

1. Connect to Wi-Fi (if needed)

  1. After booting into Ubuntu, click the Wi-Fi icon in the top-right corner
  2. Select your network, enter the password, and connect

2. Update the System

Open the terminal (Ctrl + Alt + T) and run:

sudo apt update && sudo apt upgrade -y

3. Install and Configure SSH

  1. Install SSH Server:
sudo apt install openssh-server -y
  1. Verify SSH Service:
sudo systemctl status ssh

If it's not running, start it:

sudo systemctl start ssh
  1. Enable SSH on Boot:
sudo systemctl enable ssh

4. Find the PC's Public IP Address

Open the terminal and run:

curl ifconfig.me

Note: This public IP address is required for remote SSH access.

5. Configure Router for Port Forwarding

  1. Log in to your router's admin panel (usually 192.168.x.x or 192.168.1.1)
  2. Locate the Port Forwarding section
  3. Forward port 22 to your PC's local IP address:
    • Find your local IP with:
    ip addr
    
    • Look under inet for your Wi-Fi interface
  4. Save the changes

6. Secure SSH

  1. Enable Password Authentication (default method):

    • Open the SSH configuration file:
    sudo nano /etc/ssh/sshd_config
    
    • Find and modify these lines:
    PasswordAuthentication yes
    ChallengeResponseAuthentication yes
    
    • Save the file (Ctrl + O, then Enter, then Ctrl + X) and restart SSH:
    sudo systemctl restart ssh
    
  2. Change Default SSH Port (optional extra security):

    sudo nano /etc/ssh/sshd_config
    
    • Find the line #Port 22 and change it to a custom port, e.g., Port 2222

    • Save the file (Ctrl + O, then Enter, then Ctrl + X) and restart SSH:

    sudo systemctl restart ssh
    

7. Connect Remotely via SSH

  1. From the remote machine, connect to your Ubuntu PC:
ssh username@your-public-ip
  1. If you changed the SSH port, specify it:
ssh -p 2222 username@your-public-ip
  1. When prompted, enter your Ubuntu user account password

Your PC is Ready

Congratulations! You've successfully installed Ubuntu, connected to Wi-Fi, and enabled SSH access for remote users.

PS. Huge thanks broda, I owe you one 🫶