Skip to content

Instantly share code, notes, and snippets.

@axelav
Last active May 1, 2019 20:25
Show Gist options
  • Save axelav/45ff52489de2573f2441 to your computer and use it in GitHub Desktop.
Save axelav/45ff52489de2573f2441 to your computer and use it in GitHub Desktop.

HEADLESS RASPBERRY PI SETUP WITH OS X

Creating a disk image:

http://txfx.net/2012/12/05/raspberry-pi-headless-setup/

$ sudo diskutil unmount /dev/disk1s1
$ sudo dd bs=1M if=/Users/axelav/Downloads/rpi.img of=/dev/rdisk1 # NOTE: `disk1s1` becomes `rdisk1` DONT FUCK THIS UP
$ sudo diskutil eject /dev/rdisk1

Put the SD card in the Pi & then, hook it up to an active router using a wired connection, plug it in & then:

$ ssh 192.168.0.XXX -l pi # pw: raspberry

Now that you're connected to the Raspberry Pi:

$ sudo raspi-config # do `update`
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get install vim # not necessary but you know

If you have a wifi dongle, you can set that up by:

$ sudo vim /etc/network/interfaces

Put this in there:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

But you may need some drivers. This helped a lot:

http://www.raspberrypi.org/forums/viewtopic.php?p=462982#p462982

$ uname -a
$ wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20140616.tar.gz
$ tar -zxvf 8188eu-201xyyzz.tar.gz
$ sudo install -p -m 644 8188eu.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless
$ sudo insmod /lib/modules/$(uname -r)/kernel/drivers/net/wireless/8188eu.ko
$ sudo depmod -a

Then set up your router credentials:

$ wpa_passphrase YOURSSID YOURPASSWORD
$ sudo vim /etc/wpa_supplicant/wpa_supplicant.conf

Put this in there:

network={
  ssid="YOURSSID"
  proto=WPA
  scan_ssid=1
  key_mgmt=WPA-PSK
  pairwise=CCMP TKIP
  group=CCMP TKIP
  psk=THISISGENEREATEDFORMPREVIOUSCOMMAND
  priority=1
}

At this point you should be able to ssh into the Pi via wifi.

Last bit - if you don't want to have to check your Pi's IP, you can use Avahi to alias your Pi:

$ sudo apt-get install avahi-daemon
$ sudo insserv avahi-daemon
$ sudo vim /etc/avahi/services/multiple.service

Put this in there:

<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
  <service>
    <type>_device-info._tcp</type>
    <port>0</port>
    <txt-record>model=RackMac</txt-record>
  </service>
  <service>
    <type>_ssh._tcp</type>
    <port>22</port>
  </service>
</service-group>

Then:

$ sudo /etc/init.d/avahi-daemon restart

AND FINALLY!

$ ssh pi@raspberrypi.local

Getting nodejs set up:

http://raspberryalphaomega.org.uk/2014/06/11/installing-and-using-node-js-on-raspberry-pi/

$ sudo su -
$ cd /opt
$ wget http://nodejs.org/dist/v0.10.25/node-v0.10.25-linux-arm-pi.tar.gz
$ tar xvzf node-v0.10.25-linux-arm-pi.tar.gz
$ ln -s node-v0.10.25-linux-arm-pi node
$ chmod a+rw /opt/node/lib/node_modules
$ chmod a+rw /opt/node/bin
$ echo 'PATH=$PATH:/opt/node/bin' > /etc/profile.d/node.sh

Log out & log back in. node & npm are now installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment