How to setup a headless Raspberry Pi

$ cd /Volumes/boot # this path may vary
$ touch ssh
$ vi wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB
network={
ssid="SSID"
psk="PASSWORD"
}
$ ssh pi@raspberrypi.local
$ # or ssh ubuntu@ubuntu.local
$ sudo vi /etc/hostname
$ sudo vi /etc/hosts
$ cd ~
$ mkdir .ssh
$ chmod 700 .ssh
$ # make sure to run this on the local machine, not the pi
$ scp ~/.ssh/id_rsa.pub pi@raspberrypi.local:.ssh/authorized_keys
$ # alternatively, on the pi:
$ vi .ssh/authorized_keys # and paste the public key
$ sudo reboot now
$ ssh pi@newhostname.local
$ sudo vi /etc/ssh/sshd_config
PasswordAuthentication no
sudo systemctl restart sshd.service
$ sudo apt update && sudo apt upgrade

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store