Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


raspberry_pi_headless_install_ssh_wifi

This is an old revision of the document!


Raspberry Pi / Pi Zero - headless, WiFi and SSH

This how-to expects a Linux based install host. I've used Fedora.

Install and configure

  • Download latest (RPI 3+ needs 2018-03-13 or later) Raspbian Stretch Lite.
  • Unzip:
    $ unzip 2018-03-13-raspbian-stretch-lite.zip
  • Insert the SD-card and find device name:
    $ dmesg
    
    [  477.499343] mmc0: new ultra high speed SDR104 SDHC card at address 0007
    [  477.500664] mmcblk0: mmc0:0007 SD32G 29.0 GiB
    [  477.503750]  mmcblk0: p1
  • Unmount if automounted:
    $ umount /dev/mmcblk0p{1,2}
  • Write image to SD card:
    $ sudo dd bs=4M if=2018-03-13-raspbian-stretch-lite.img of=/dev/mmcblk0 conv=fsync oflag=direct status=progress
  • Mount SD card (reinsert card, or mount manually), find partitions:
    $ sudo fdisk -l /dev/mmcblk0
    
    Disk /dev/mmcblk0: 29 GiB, 31117541376 bytes, 60776448 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x84fa8189
    
    Device         Boot Start     End Sectors  Size Id Type
    /dev/mmcblk0p1       8192   92159   83968   41M  c W95 FAT32 (LBA)
    /dev/mmcblk0p2      92160 2534887 2442728  1,2G 83 Linux
  • Add the file 'ssh' to root of SD card to enable SSH:
    $ touch /run/media/<username>/boot/ssh
  • Generate WiFi config:
    $ cd /run/media/<username>/rootfs
    $ wpa_passphrase YOUR_SSID YOUR_PASSWORD
  • Add generated config, (remove the plaintext passphrase):
    $ sudo vi etc/wpa_supplicant/wpa_supplicant.conf
    
    country=<Your country, e.g. US, NL, GB>
    network={
            ssid="<your SSID>"
            psk=<your PSK key>
    }
  • Unount SD-card:
    $ cd
    $ umount /dev/mmcblk0p{1,2}
  • Insert card into RPI, power on.
  • Check DHCP leases for IP-address.
  • Log in to new RPI, the initial password is raspberry:
    ssh pi@<DHCP IP-address>
  • Add other accounts, remove pi user or change the password.
  • Add additional users, remove unwanted users.
  • Configure the Raspberry Pi; change hostname, boot options, locale, timezone, disable ports, etc.
    raspi-config
  • Reboot
  • Update and reboot:
    sudo apt-get update
    sudo apt-get dist-upgrade
    reboot

Update firmware

  • Install rpi-update:
    $ sudo apt-get install rpi-update
  • Update firmware:
    $ sudo rpi-update

WiFi status

  • Show current status:
    iwconfig
    wpa_cli status
  • Wavemon:

Disable HDMI

Add lines below to /etc/rc.local, above exit 0
# Disable HDMI
/usr/bin/tvservice -o
raspberry_pi_headless_install_ssh_wifi.1538807357.txt.gz · Last modified: 2018/10/06 06:29 by admin