Setup Headless Raspberry Pi With Raspbian

Dec 29, 2017   #raspberrypi  #raspbian 

After setting up the sd card with raspbian for booting a raspberry pi 3 the first time I want to be able to connect to it without hooking up a keyboard and a display.

Enabling SSH

I use a mac and after installing the image on the SD card I am left with the boot partion mounted on the system in the /Volumes directory.

$ mount | grep boot
/dev/disk2s1 on /Volumes/boot (msdos, local, nodev, nosuid, noowners)

With the boot partion mounted in /Volume enabling ssh at boot for rasbian is done by creating an empty file named ssh there:

touch /Volumes/boot/ssh

Now when your raspberry pi boots with the sd card in it ssh the daemon will start.

Configuring wireless

If you have a raspberrypi 3 wireless can be setup automatically by creating /Volumes/boot/wpa_supplicant.conf file with the following information:

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

When the pi boots /boot/wpa_supplicant.conf will be moved to /etc/wpa_supplicant/wpa_supplicant.conf

Connecting over ssh

After booting your pi you should be able to connect to your pi using your terminal. If there are no other raspberry pis on your network you might be able to connect using the zeroconf hostname raspberrypi.local using the following command:

ssh pi@raspberrypi.local

If that does not work you might need to look at your router to see if you can determine the ip address that was assigned to the pi. Using nmap to scan the network is also an option for finding your ip address.