Raspberry Pi Setup
Follow these steps if you have a fresh Raspberry Pi an SD card with no running OS. This one will allow you to set up your Pi without having to connect a monitor or keyboard. You will need to have access to router for determining local the IP of Pi when it boots and joins the network.
If you already have a Pi with your preferred setup, you can skip to step 5.
Steps
1. Download and install the Raspberry Pi imager
Go to https://www.raspberrypi.com/software/ and download the imager for your OS (Mac, Windows, Linux).
2. Write Raspberry Pi OS Lite to your SD card
Select "Raspberry Pi OS (other)" > "Raspberry Pi OS Lite (32-bit)".
Other versions work, but there is no need for the desktop GUI.
3. Preconfigure wifi and ssh on startup
On the same machine running the imager, create a wpa_supplicant.conf
file with the following contents and your ssid and psk:
country=us
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={
scan_ssid=1
ssid="<your wifi ssid>"
psk="<your wifi passcode>"
}
Copy the file to root of your SD card boot folder. For example, on the Mac:
cp wpa_supplicant.conf /Volumes/boot/
To enable ssh on start up, create an empty file named ssh
(no extension) in the same boot folder
touch /Volumes/boot/ssh
4. Boot your Pi and connect to it via ssh
# default password is "raspberry"
ssh [email protected]
Run sudo raspi-config
to change your default password to something more secure. I also recommend generating a ssh key and adding it to authorized_keys
.
-
On your host machine connected to the Pi, run
ssh-keygen -t ed25519
.Choose "enter" for the defaults.
-
Output the contents of your public key for pasting on the Pi.
cat ~/.ssh/id_ed25519.pub
-
On the Pi, create a
.ssh
folder and copy in the public key to authorized-keys.cd ~
mkdir .ssh
cd .ssh
echo "<contents of public key from step 2>" > authorized-keysThe next time you connect via ssh, you should not be prompted for a password.
4. Configure Pi to auto login on start up
Run sudo raspi-config
again. Select Boot Options
and choose Console Autologin
.
5. Install git, vim, and Node.js
sudo apt-get update
sudo apt-get install vim git
Install the latest LTS build of Node.js (currently v16.XX.X) for armv61, which can be found @ https://unofficial-builds.nodejs.org/download/release/v16.XX.X/node-v16.XX.X-linux-armv6l.tar.xz
# Example installing v16.14.0
wget https://unofficial-builds.nodejs.org/download/release/v16.14.0/node-v16.14.0-linux-armv6l.tar.gz
tar -xzf node-v16.14.0-linux-armv6l.tar.gz
cd node-v16.14.0-linux-armv6/
sudo cp -R * /usr/local/
export PATH=$PATH:/usr/local/bin
6. Install yarn and pm2
Yarn will be used for installing Node.js packages and pm2 for managing the running application.
curl -o- -L https://yarnpkg.com/install.sh | bash
# update .bash_aliases
# set global timeout to a higher number. Will be needed on devices with less power like the Pi Zero.
yarn config set network-timeout 600000 -g
yarn global add pm2
# generate the start up script
pm2 startup