Categories
Computer

Raspberry Pi: headless wireless setup using a mac

I just bought a cute little Raspberry Pi Zero W as a toy for myself. I don’t intend to use it with a screen or any other peripherals. Just as a generic linux network device to run some services on. Here is how I set it up only using a SD card reader and my macbook. No screen, keyboard or network cable required.

What you need

  • Raspberry Pi with WiFi module (I used the Pi Zero W)
  • SD-Card (I used a 64GB micro SD)
  • Macbook with card-reader
  • Wireless Network (Mine was the hotspot from my phone)

Get the linux images

I torrented the Raspbian Desktop (Lite should be sufficient) Image from the official website.

Write the image to SD

I followed these more detailed instructions. Basically enter the following in the Terminal:

  • determine the disk «number» of your SD, eg disk2: diskutil list
  • unmount that SD: diskutil unmountDisk /dev/disk«number»
  • transfer image: sudo dd bs=1m if=«path/to/image.img» of=/dev/rdisk«number» conv=sync

Setup wireless network and SSH access

If you have a network cable you don’t need to do this. But if you want to do it wirelessly here is how:

Create a file called wpa_supplicant.conf on the SD Card. Replace the region code, network id and network password with yours:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=«your_ISO-3166-1_two-letter_country_code»

network={
    ssid="«your_SSID»"
    psk="«your_PSK»"
    key_mgmt=WPA-PSK
}
ctrl_interface=/var/run/wpa_supplicant

Also create a empty file named ssh on SD card.

Boot!

Pop the SD into your Pi, plug in the USB power and wait a second. Now you can check on your router or mobile phone for a newly logged in device and it’s IP address.
I saw on my phone that there is a newly connected device but not the IP so I ran arp -a on my mac to find out.

Now let’t try to connect to it: ssh pi@«IP Address» You will have to type in yes, because its the first time your mac is connecting to this device. Then enter the default password raspberry now, if everything went ok your logged into your Rasperry Pi. First thing you want to do now is to change the default password to something else by running sudo raspi-config

One reply on “Raspberry Pi: headless wireless setup using a mac”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.