Skip to content

Instantly share code, notes, and snippets.

@vasilisvg
Last active November 3, 2019 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasilisvg/6b6016d926f34b9ddffa36a1dbdd54d3 to your computer and use it in GitHub Desktop.
Save vasilisvg/6b6016d926f34b9ddffa36a1dbdd54d3 to your computer and use it in GitHub Desktop.
How to set up a headless pi

Download the latest version of Raspbian Lite, which is the version without a desktop environment.

First install Raspbian onto a mini sd card using a tool like Etcher. When the burning is done, mount the drive onto your computer. If we want to access the Raspberry PI using SSH (which we want) we need to add two files to the root of the mounted drive before we can use it in the Pi:

  • A file called ssh with no content.
  • A file called wpa_supplicant.conf which should have your wifi credentials and look something like this (change the country to your country code):
country=NL
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
	ssid="Network Name"
	scan_ssid=1
	psk="The password"
}

Put the card into the Raspberry Pi and start it up. You can now connect to the pi using your terminal, with ssh. There are several ways to find the ip address of your Pi, I use the web interface of my router. Find it, and then ssh to it:

ssh pi@192.168.178.64

The default password is raspberry

Now change the password and network name:

echo "pi:newPassword" | sudo chpasswd
sudo sed -i "s/raspberrypi/new name/" /etc/hostname
sudo sed -i "s/raspberrypi/new name/" /etc/hosts

Expand the filesystem to use the complete disk

sudo raspi-config

Use your arrow keys to select Advanced Options > Expand Filesystem Select OK, and restart the Pi. Now ssh into the Pi again (use your new password).

sudo apt update
sudo apt dist-upgrade

You’re done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment