diff --git a/content/posts/2023.04.27.raspberry-pi-headless-setup.md b/content/posts/2023.04.27.raspberry-pi-headless-setup.md new file mode 100644 index 0000000..a86bbed --- /dev/null +++ b/content/posts/2023.04.27.raspberry-pi-headless-setup.md @@ -0,0 +1,62 @@ +--- +title: "Fully Headless Setup for Raspberry Pi" +date: 2023-04-27T20:40:00-04:00 +toc: false +images: +tags: + - homelab +--- + +I always hit this issue: I have a Raspberry Pi I want to set up, but I don't +want to break out the cables to hook it up to a monitor and keyboard. +Luckily, the Raspbian OS actually has built-in features for this. +Just follow these steps: + +```sh + +# Extract the Raspbian OS Lite image +xz -d -lite.img.xz +# Flash the image to the SD card +dd if=-lite.img of=/dev/sdX bs=4M +# Mount the boot partition +mount /dev/sdX1 /mnt +# Enable SSH +sudo touch /mnt/ssh +``` + +Create a file `/mnt/wpa_supplicant.conf`, with the contents: + +``` +country=<2 letter country code here> +ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev +update_config=1 + +network={ + ssid="wifi ssid here" + psk="wifi password here" +} +``` + +Set up your user: + +```sh +# replace username and password below +echo username:(echo 'password' | openssl passwd -6 -stdin) | sudo tee /mnt/userconf +``` + +Optional: Set up a hostname. + +```sh +sync +umount /mnt +mount /dev/sdX2 /mnt +# replace host below +echo host | sudo tee /mnt/etc/hostname +``` + +Otherwise, just `sync && umount /mnt` and you are done. + +If you did set up the hostname, and you have `.local` domains with Avahi set up, +you should be able to `ssh username@host.local`. If you didn't, or if that +doesn't work, use your router's DHCP page to find the IP address for the +Raspberry Pi.