DEV Community

Blaine Carter
Blaine Carter

Posted on • Originally published at learncodeshare.net on

Quick and Easy Raspberry Pi Setup

So, you have a shiny new Raspberry Pi and you’d like to install Linux on it.

This is a short guide to help you get Raspbian installed and configured for Wifi and SSH access. You should be able to follow this guide even if you don’t connect a keyboard or monitor to your Pi.

NOTE: In order to complete all of the steps in this guide, you will need to be able to access and edit files in an ext4 filesystem. I will mark these steps with [ext4]. This may require additional steps and/or software for Windows systems.

First up, you will need to download a couple files.

  • Raspbian
    I usually download the image from raspberrypi.org. There are two images available. The desktop image comes with a GUI front end and a few pre-installed applications. The lite image is a ‘headless’ install, meaning you will boot to a command prompt and there is no GUI desktop installed. This guide will work for either version, pick whichever version you want.
  • Etcher Using Etcher makes it easy to flash an image to your sd card.

Put the SD Card in Your Computer

For the next few steps, keep the SD Card in your computer. You will not put the card in your Pi until we get to the “Boot your Pi” section below.

Flash Raspbian to the SD Card

Run Etcher:

  1. Chose the Raspbian zip file you downloaded above.
  2. Select your SD Card from the list. WARNING: Etcher does it’s best to make sure it only shows SD Cards in the list, but you should always make sure it’s the card you want to install to, the selected drive will be formatted!
  3. Click Flash.

If you open your favorite file explorer you should now see two new drives listed.

  • boot
  • rootfs [ext4]
Enable SSH Access
  1. Change into boot. (Modify the ‘cd’ command below to match the path to boot on your system.)
  2. Create an empty file called ‘ssh’.
cd boot touch ssh

That’s it. The first time you boot your Pi ssh will automatically be enabled. (Don’t boot it up yet.)

Connect Without a Password

Having to type a password everytime you SSH or SCP to your Pi gets old after a while. If you don’t mind typing the password every time you can skip this step.

Add your public key to your Pi [ext4]:

  1. Locate the ssh public key you want to use (example ~/.ssh/id_rsa.pub). If you don’t already have one, you can follow the steps in this guide.
  2. Change into the pi home on rootfs. (Modify the ‘cd’ command below to match the path to rootfs on your system.)
  3. Create the .ssh directory.
  4. Append your public key to the authorized_keys file. (You can repeat this step to append as many keys as you need for the different systems you intend to use.)
cd rootfs/home/pi install -d -m 700 .ssh cat ~/.ssh/id\_rsa.pub \>\> .ssh/authorized\_keys

If you’re not able to access the ext4 partition from your operating system you can follow this guide on raspberrypi.org after you boot up the Pi.

Enable Wifi [ext4]
  1. Change into rootfs/etc/wpa_supplicant.
  2. Edit wpa_supplicant.conf. (You may need sudo to edit this file.)
  3. Append the following to the end of the file. Replace “Your SSID” and “Your WPA Password” with the values to connect to your Wifi.
network={ ssid="Your SSID" psk="Your WPA Password" key\_mgmt=WPA-PSK }
  1. Save the file.

If you’re not able to access the ext4 partition from your operating system you can follow these instructions after you boot up the Pi with the following changes.

  1. Connect a keyboard and monitor to your Pi.
  2. Change into /etc/wpa_supplicant.
  3. Continue with step 2 above.

Now it’s time to

Boot your Pi

Put the SD Card in your Pi and boot it up.

If you’re not connecting your Pi to a display, you should be able to get its IP address from your Wifi Router admin page.

  1. Connect with ssh.
  2. Change the default pi user password. (default password: raspberry). Even though we set up access using a public key, the Pi can still be accessed with a password so it’s a good idea to set a new password.
  3. Run an update.
ssh pi@192.168.0.34 passwd sudo apt-get update

Do Something Fun

At this point, you have a little Linux machine all set up and ready to use for your projects. Go do something fun with it.

If there are other configurations you’d like me to add to the guide please leave a comment.

Oldest comments (0)