Installing Ubuntu on a RPi

  1. I will be using  Ubuntu 16.04 LTS ‘classic’.
    On the RPi site they mention Rpi pic
    the Snappy version of Ubuntu for IoT. This is not the one I want, as it doesn’t use the normal Ubuntu method for getting software (apt-get). The classic Ubuntu image is linked here. This image has SSH pre-installed, so you can boot without ever using a monitor.
    Writing the image to an SD card on Windows can be done with Win32 Disk Imager
  2. With the Pi plugged into my LAN I can find it using Network IP Scanner for Android. I use MobaXTerm to ssh into my Pi. On first login a new password will be required (the initial password is ubuntu).
  3. Set time zone
    sudo dpkg-reconfigure tzdata
  4. Set the hostname
    hostnamectl set-hostname new-hostname
  5. Edit /etc/hosts (sudo nano /etc/hosts) and add a line which reads: hostname

    (Where hostname is the new hostname, as here)

  6. Add public key auth for SSH
    Note: it’s a good idea to do this step locally, since you will be locked out remotely if done incorrectly

    • Generate an SSH key as here (Digital Ocean Ubuntu Guide).
    • Copy that key to an authorized_keys file
      cd "/home/ubuntu/.ssh/"
      cat >> authorized_keys
    • Follow step 5 from the Digital Ocean Ubuntu Guide.
      sudo nano /etc/ssh/sshd_config

      I changed some arguments in the following lines as follows:

      PermitRootLogin prohibit-password
      PubkeyAuthentication yes
      AuthorizedKeysFile      %h/.ssh/authorized_keys
      PasswordAuthentication no

      Change the port for SSH in sshd_config for internet use.

  7. Reboot SSH (perhaps start a new SSH instance after this step, before closing the existing instance)
    sudo service ssh restart
  8. sudo apt-get update
    sudo apt-get upgrade
  9. Add auto security updates.
    sudo apt-get install unattended-upgrades
    sudo dpkg-reconfigure unattended-upgrades
    sudo nano /etc/apt/apt.conf.d/50unattended-upgrades
  10. Add email sending capability.
  11. Using the ‘Additional Recommended Steps for New Ubuntu 14.04 Servers’ instructions:
    • Set a firewall; allow SSH and samba through the firewall for windows file sharing. Samba ports: UDP/137,138 TCP/139,445
      Finish the firewall settings..
    • Configure NTP Synchronisation.
    • Swapfile is already created in step 5.
  12. Perhaps change user home directory permissions..
    sudo chmod 0750 /home/username
  13. Now we can go on to configure Samba if required.

4 Replies to “Installing Ubuntu on a RPi”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.