Headless Pi
Apr 7, 2017 10:27 · 417 words · 2 minutes read
This is a just a short post on preparing a Raspbian OS microSD card with ssh
enabled and wifi preconfigured so as to avoid requiring any physically connected keyboard or monitor to initially set up a Pi as a headless server.
Download and flash Raspbian OS
The first order of business is getting the operating system image. Visit the official raspbian page and pick either the full Raspbian Jessie version or the Raspbian Jessie-Lite version. If you are planning to run the full graphical desktop and connecting via VNC, then get the full version. For connecting via ssh
(as in this post) the Lite version suffices.
The simplest cross-platform way to flash the image to a microSD card these days is with the Etcher program. Detailed instructions for this, and other system specific methods of writing an image can be found at raspberrypi.org.
Preconfigure ssh and wifi
After ejecting the microSD card, re-insert it back into your computer and it should automount. There are two partitions on this card, the /boot
partition and a /
root filesystem partition (you may only see the boot partition, which is the one we need to modify now).
We want to add two files to the top level of the /boot
partition:
- add an empty file simply named
ssh
- add a file named
wpa-supplicant.conf
with the following contents
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOUR SSID"
psk="YOUR PASSWORD"
}
Obviously, you’ll substitute your actual SSID and PASSWORD if you want to have even a remote chance of this working. Double check the details.
Eject or umount
the microSD card, put it in your Pi and plug in the power.
Login and configure
Give it time to fully boot up — the first boot can take extra time — then try pinging it with ping raspberrypi
or ping raspberrypi.local
. If you do not get a response after a reasonable wait, try logging in to your router to see a list of all connected devices and their assigned IP addresses to see if you can identify your pi in the list. Log into your pi via ssh
(or Putty on Windows) with the hostname or IP address:
$ ssh pi@raspberrypi
The default password for user pi
is raspberry
. Once logged in, start the configuration program:
$ sudo raspi-config
Change your password, assign a new hostname if desired, and set your local language and timezone. Then reboot and reconnect to your Pi and update/upgrade your system:
$ sudo apt-get update
$ sudo apt-get upgrade
Enjoy!
__END__