Installing and Setting up Ubuntu

Pieter P

Installation

  1. Download the Ubuntu Server image from https://ubuntu.com/download/iot/raspberry-pi-2-3
    wget -P /tmp/ http://cdimage.ubuntu.com/releases/bionic/release/ubuntu-18.04.3-preinstalled-server-arm64+raspi3.img.xz
  2. Then write the disk image to your SD card
    xzcat /tmp/ubuntu-18.04.3-preinstalled-server-arm64+raspi3.img.xz | sudo dd of=/dev/mmcblk0 bs=32M
    Be careful when using dd, if you specify the wrong output (of=...), it'll overwrite everything on that device, so it's easy to accidentally destroy your computer.
  3. Install the SD card into the Raspberry Pi, connect it to a network using Ethernet, and power it up.
    If you don't have an Ethernet network to connect the Pi to, you can configure the WiFi first, as explained here: WiFi Setup
  4. Use your favorite method to find its IP address. You can find it in your router's settings, with an app like Fing, or by using a command line tool like nmap.
  5. Connect to the Raspberry Pi over SSH
    ssh ubuntu@192.168.1.100
    Replace the IP address with the one you found in the previous step.
    You'll be prompted a password, the default one is ubuntu.
  6. Follow the instructions to change the default password and connect again.

SSH Configuration

  1. Set the hostname:
    sudo hostnamectl set-hostname rpi3
  2. Install the avahi-daemon package to enable mDNS:
    sudo apt install avahi-daemon
  3. If you already had the avahi-daemon installed, you have to restart it to use the new hostname:
    sudo service avahi-daemon restart
  4. Close the SSH connection:
    exit
  5. You should now be able to reach the Pi using its mDNS hostname:
    ping rpi3.local -c3
  6. Create an SSH configuration for the Pi on your computer, so you can connect to it without having to specify the hostname or username:
    cat >> ~/.ssh/config << 'EOF'
    Host RPi3
        HostName rpi3.local
        User ubuntu
    EOF
  7. Add your public key to the Pi's authorized_keys, so you can connect to it without entering the password each time:
    ssh-copy-id -i ~/.ssh/id_rsa.pub RPi3
    If you don't have an SSH key pair yet, you can follow these instructions on how to create one: DigitalOcean - How to Set Up SSH Keys.
  8. You can now try to connect to it without having to specify the hostname or username, and without having to enter your password:
    ssh RPi3