Setting up Raspbian on the Raspberry Pi 3

This is part #3 of my adventures in Building the Internet of Things with the Raspberry Pi. You can read about Getting started with Raspberry Pi 3 and my first Hello Blinky 1.0 with the Raspberry Pi 3.

In this post I want to install Raspbian via NOOBS, configure the security-critical settings and install the necessary packages to access the Raspberry Pi GUI from a computer with a Remote Desktop Connection.

Install Rasbian via NOOBS

This step is pretty straightforward: you will need a monitor, keyboard and mouse. If you have a pre-installed SD card with NOOBS, select to install Raspbian. Otherwise you can prepare an SD card with NOOBS. See here.

Install packages

Connect the RPi to the internet via Wifi.

Via console

sudo apt-get install xrdp (Remote Desktop)
sudo apt-get install geany (Notepad++ for Linux)

Hints:

  • the console remembers commands after reboot.
  • sudo – super user do
  • apt – package manager

Via UI

Menu => Preferences => Add/Remove software

Do every few weeks:

sudo apt-get update

Hint: gets the new list of packages.

sudo apt-get upgrade

Hint: downloads and installs the updates.

Network

Check ip address:

ifconfig

Hint: Similar to ipconfig and displays following configuration: eth0 – cable, lo – localhost, wlan0.

Set static ip address

gksu geany

Hint: run Geany with admin rights to change configuration files, otherwise it’s write-protected. Important: it’s another session!

/etc – contains config files
/etc/network/interfaces – network configuration

Add following configuration:

iface eth0 inet static

address 192.168.0.1
netmask …
gateway …

or

iface eth0 inet manual

Restart network:
sudo etc/init.d/networking restart

Remote desktop

Control panel => Network and Internet => Connections => Local network => Properties => IPv4 => Set IP address and Mask

ping RPi IP
Remote desktop to RPi IP

Hint: we can have multiple sessions with same user directly on the RPi and with remote desktop at the same time.

Security settings

Changing the login information is critical, default login is the same for all RPi.

Menu => Raspberry Pi Configuration

=> System:
– change password,
– change hostname,
– boot to desktop/CLI (command line shell, can start GUI anytime from CLS)
– autologin is ok

– SSH server; DON’T run on port 22
– Don’t connect RPi direct in internet, use router, vpn

– Rename default username Pi: create temporary user without home, make user admin, rename pi and move home

Menu => Interfaces

  • Enable SSH (Putty)

24/7 continuous operation

  • Watchdog – auto-restart when problems occur => activate, configure and install Watchdog
  • fail2ban – for connection via SSH, 5 tries to login and lock out for 10 minutes, against brute force attacks

sudo apt-get install fail2ban

sudo nano filename (GNU Nano text editor)

Links: