Raspberry Pi 2 setup notes: part 1

By Will Angley
28 Mar 2016

I got a Raspberry Pi 2 last spring, and between then and now have forgotten how I set it up. This time I’m taking notes, in the hopes of not forgetting for a third time.

My Pi tends to face the Internet in one way or another, and will run for far longer than anything other than the Network Box I use as a home router. So these instructions are closer to what you would use to set up a full-fledged server than what you might be used to.

For more options, and more explanatory text, I’d recommend the Early Release Raspberry Pi Cookbook.

Imaging the microSD card

  1. Download the latest Raspbian Lite

    Why Lite? My Pi spends most of its time running without a monitor, and the graphical bits are only worthwhile in practice you’re connected directly to an HDMI display. They’re either frustrating or unusable (i.e. Minecraft Pi) over VNC.

  2. Insert microSD card into SD adapter, insert adapter into Mac.

  3. Follow the official Mac instructions for installing images using command-line tools. tl;dr

     % diskutil list
     % diskutil unmountDisk /dev/disk2
     % sudo dd bs=1m if=Downloads/2016-03-18-raspbian-jessie-lite.img of=/dev/rdisk2
    
  4. Then drag the boot disk to the Trash to eject it.
  5. Remove the adapter from the Mac. Remove the microSD card from the adapter.

Preparing the Pi (local)

We’ll make sure the Pi can boot, and change the password, before connecting it to the network.1

  1. Insert the microSD card into the Pi.
  2. Connect the Pi to a USB keyboard and HDMI display
  3. Connect the Pi to power. It will boot and display messages on the monitor.
  4. Log in with the default credentials. (tl;dr pi:raspberry)
  5. Run sudo raspi-config
    1. Select “1 Expand Filesystem”
    2. Select “5 Internationalization Options” and configure the connected keyboard, if it’s a Mac keyboard (like mine) or otherwise not standard.
    3. Select “<Finish>” and accept the reboot when offered.
  6. Log in again and run sudo raspi-config
    1. Select “2 Change User Password” and change it to something strong, like a 1Password-generated password.
    2. Select “<Finish>”
  7. Log out (Ctrl+D).
  8. Log in again. Make sure you still know your strong password :wink:.
  9. Shut down with sudo shutdown -P now.
  10. Once the Pi is shut down, disconnect it from power and peripherals.

Preparing the Pi (network)

  1. Move the Pi somewhere where you have an Ethernet connection. Connect it to network, then to power.
  2. Wait 20 seconds - these boot quickly - then find it on the network. The easiest way to do this is with your router’s configuration page, if it shows connected devices.2
  3. Log into the Pi remotely: ssh pi@192.168.12.34 using your new password. Make sure you can still log in.

If you’re coming from across the Internet, you can either port forward a connection to your Pi or bounce it through another computer you can reach at home:

ssh -o ProxyCommand="ssh -W %h:%p you@router.example.com" pi@192.168.12.34

Up next: setting up automatic maintenance.


  1. This is especially important if you’re on a network that you share with devices with questionable security. Or if you’re behind a router that gives devices public IPv6 addresses by default. 

  2. If your router doesn’t show connected devices in a Web interface, you’ll have a bit more work to do; a couple gentle ways of doing this are:

    1. connect a monitor and keyboard to the Pi where it is, and run ip -4 addr to find the address of the Pi.
    2. log into the router, or another host connected to the same Ethernet network as the Pi, and look at its ARP table. On Linux, use cat /proc/net/arp to do this; on Mac, arp -a.
    3. Use IPv6 neighbor discovery: ping6 -I en0 ff02::1.

    The Debian image on a Raspberry Pi does not respond to broadcast pings on IPv4, for what it’s worth.