The single-board computers specification:

  • 1GHz, single-core CPU
  • 512MB RAM
  • 802.11 b/g/n wireless LAN
  • Bluetooth Low Energy (BLE)

I got the board for RM40.00 from a local online store. Here's what I need to setup on my laptop, without monitor, bluetooh wireless keyboard and mouse.:

  1. Raspberry Pi Zero W.
  2. 32GB Micro SD Card.
  3. Micro USB power supply.

Raspbian on SD card

  1. Download latest Raspberry Pi OS, RASPBIAN STRETCH LITE.
  2. Download and install Etcher.
  3. Mount the SD card. Flash the OS image to the SD card.
  4. Re-mount the SD card.

On mac, it is mounted to /Volumes/boot.

Goto terminal/console and check out the SD card content.

$ cd /Volumes/boot

Enable SSH

Create an empty file called ssh.

$ touch ssh

Enable WiFi

Create a config file called wpa_supplicant.conf.

$ touch wpa_supplicant.conf

Insert the following content to the config file, with correct network credential.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="WIFI_SSID"
    psk="WIFI_PASSWORD"
}

Boot up and SSH in

Remove SD card from laptop and put it in Pi and power up.

Wait for about 30-60 seconds for Pi to fully boot up and ping it to see if it's alive.

$ ping raspberrypi.local

Now you can SSH into Pi.

$ ssh [email protected]

Default password is raspberry.

Others

Pi comes with a handy configuration tool raspi-config. Use it to:

  • Change password and hostname.
  • Configure network settings.
  • Configure start-up options.
  • Set up language and regional settings.
  • Configure connections to peripherals.
  • Overclocking.
  • System update.
$ sudo raspi-config

Securing Raspberry Pi

Add new user, don't use default pi user.

$ sudo adduser jewei

# Add user to sudo group
$ sudo adduser jewei sudo

Add user to sudoer /etc/sudoers.d/010_pi-nopasswd.

Passwordless SSH login.

# generate public/private rsa key pair
$ ssh-keygen -t rsa -b 2048 -c [email protected] -f id_durian

# copy the key to pi
$ ssh-copy-id -i ~/.ssh/id_durian.pub [email protected]

Disable Password Authentication on Pi.

$ sudo vim /etc/ssh/sshd_config

Modify these directives:

PasswordAuthentication no
PermitRootLogin no
UsePAM no
PubkeyAuthentication yes
ChallengeResponseAuthentication no

Reload SSH daemon.

$ sudo systemctl restart ssh

Test login.

$ ssh [email protected]

Remove default pi user.

$ sudo deluser -remove-home pi

Install a firewall.

$ sudo apt install ufw
$ sudo ufw allow ssh
$ sudo ufw enable
$ sudo ufw status

Install fail2ban.

$ sudo apt install fail2ban
$ sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

  • Raspbian release note. link
  • Etcher changelog. link
  • Raspberry Pi documentation. link