How to headless Raspberry Pi

A guide to setup a Raspberry Pi 3 Model B (RPI) to be used without screen or keyboard by using ssh. I could not find any on a single source so I created mine.

Flashing the Raspberry Pi

First you need to flash the sd card with an operative system. I am using Raspbian but other options are available.
  1. Download rasbpbian lite (no desktop client needed)
  2. Flash the image on the SD card. I used the Startup Disk creator that comes with Ubuntu by default. This process takes a few minutes.

Setting up WiFi and remote access (ssh)

Now setup the RPI to connect to an acces point by default. As you do not have (or don’t want to use) an extra screen and keyboard to connect to the RPI you have to do everything by modifying config files.
  1. Mount the sd card in your linux machine (desktop).
  2. Use wpa_passphrase to get the encripted password of your network replacing network_ssid and network_pass with your network data:
  3. wpa_passphrase "network_ssid" "network_pass"
  4. Edit the file /sdcard_path/rootfs/etc/wpa_supplicant/wpa_supplicant.conf on the sd card. Add the output of wpa_passphrase at the end of the file removing the `#psk` line. I am using a WPA2 network:
  5. network={
  6. Create a file called ssh on the boot partition of the RPI
  7. touch /sdcard_path/boot/ssh
  8. Remove the SD card from your desktop machine, insert it on the RPI and power on your RPI, wait a few seconds to allow it to boot.
  9. Find the IP address of the RPI on your router seetings or you an use the Android APP Fing to view the devices connected to your network.
  10. Connect to your RPI using ssh. The default user is `pi` and the default password is `raspberry`
ssh pi@ip_address
If you see a message like this you are done!
Linux raspberrypi 4.14.34-v7+ #1110 SMP Mon Apr 16 15:18:51 BST 2018 armv7l
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $

Some extra steps:

  1. Update your RPI
  2. sudo apt update && sudo apt upgrade
  3. Change the root password
  4. pi@raspberrypi:~ $ passwd
    Changing password for pi.
    (current) UNIX password:
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully