How to setup a Raspberry Pi 3 headless, without monitor, mouse or keyboard

by Jannik Arndt

I bought a raspberry pi as a smart home automation server. Here’s how to set it up without connecting a monitor, mouse or keyboard. All you need is an ethernet cable.

1. Prepare the SD card

  1. Download Raspbian from
  2. Copy it to the SD card, using
    • ApplePi Baker or
    • Etcher or
    • your Terminal: shell sudo dd bs=1m if=[path to img file, e.g. "2017-08-16-raspbian-stretch.img"] of=[path to rdisk, e.g. "/dev/rdisk2"] conv=sync
  3. Enabled ssh access for one start by creating an ssh file in the boot folder: shell touch /Volumes/boot/ssh
  4. Eject the SD card (via the button in Finder or diskutil eject /dev/disk2)

2. Prepare your Mac

You need to enabled Internet Sharing on MacOS so the Pi can connect to it. Go to System Settings > Sharing:

3. Configure SSH access

This assumes that you have an ssh key. If not or you don’t know what that is: An ssh key consist of two files: A private and a public one. The private one (id_rsa) is on your computer and works like a password (so do not share it!). The public one ( is on other computers and identifies you. It only works together with your private key, so don’t loose it. Your public key is on your computer as well so you can easily share it.

You can find both keys with

$ ls -l ~/.ssh
total 120
-rw-------  1 jannikarndt  staff  1766 Jan  3  2017 id_rsa
-rw-r--r--@ 1 jannikarndt  staff   403 Jan  3  2017

If you don’t have a key, GitHub has a great article on how to create one.

  1. Copy your ssh key to the pi:

    cat ~/.ssh/ | ssh pi@raspberrypi.local "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
  2. SSH into the pi:

    ssh pi@
    pi@'s password: raspberry

    The preconfigured password is raspberry. A good reason to change it right away:

  3. Change your root password:

    sudo raspi-config

  4. Add your wifi credentials in 2 Network Options > N2 Wi-fi

  5. Permanently enable ssh access in 5 Interfacing Options > P2 SSH.

4. Install oh-my-zsh

And now, for the grand finale, you can (should / will want to) install a proper shell, i.e. oh my zsh:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install git zsh
chsh -s /bin/zsh
sh -c "$(curl -fsSL"

5. Continue

Great! Now you can use your Pi, for example


I recently created a wonderful bug.

This is a basic example how to implement oAuth2 using Akka HTTP and Scala. It provides three endpoints. From the clients point of view:

  • / — publicly accessible, returns “Welcome!”,
  • /auth — provide your username and password, receive an access_token in return,
  • /api — secured by oAuth, send the access_token in a header to gain access.

From the server’s point of view:

  • / — publicly accessible, do nothing,
  • /auth — receive basic auth credentials, verify they’re in the list of known credentials, create an access_token, return it,
  • /api — receive authorization header, check if access_token is in list of valid tokens.

Since oAuth tokens are short lived, the server also has to invalidate expired tokens.

Getting a Akka HTTP-based backend up and running on Heroku for free can be done in less then 30 minutes — if you know the tricks.