Skip to content

Instantly share code, notes, and snippets.

Last active Aug 21, 2021
What would you like to do?

Raspberry Pi Zero setup without keyboard and display adapters

Raspberry Pi comes with HDMI mini socket, and the Adapter HDMI mini to HDMI costs 4-5 €. However, I did not have one laying around so I flashed the Micro SD card I had and added the wifi configuration to it.

Then I can SSH directly to the box using the dynamic IP address my router provides.

  1. Stick the Micro SD to laptop with an adapter

  2. Download Raspberry Pi OS Lite from

  3. Use a flasher tool, for example Etcher. Flashing wipes all data from the card!

  4. Create file wpa_supplicant.conf with this content:

     ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

    The file will be editable later on in location /etc/wpa_supplicant/wpa_supplicant.conf inside the Raspberry Pi.

  5. Create an empty file ssh.

  6. Copy both files onto the root of the flashed Micro SD.

  7. Find out the current Pi's IP address, for example with Terminal command

  8. (which lists all devices on your local network)

      arp -a
  9. Boot the Raspberry Pi and SSH to it:

     ssh pi@ # 
  10. Disable IPv6

    Edit system configuration file.

    $ sudo nano /etc/sysctl.conf
    # Add this to the end of the file
    net.ipv6.conf.eth0.disable_ipv6 = 1

    Disable IPv6 also by reloading /proc stuff.

    $ sudo nano /etc/rc.local 
    # Add this right above the `exit 0`
    /etc/init.d/procps force-reload

    You can test this works like this, and the latter command should not return anything.

    sudo sh /etc/rc.local
    ifconfig | grep inet6.
  11. Update the Raspberry Pi to use fixed IP address by editing DHCP configuration:

    sudo nano /etc/dhcpcd.conf

    Look for section "# Example static IP configuration" and read through. You probably need to add something like this at the end of the file:

     interface wlan0
     static ip_address=
     static routers=
     static domain_name_servers=

    interface is wlan0 for wifi, and eth0 for wired connection.
    ip_address is your fixed IP address (and keep the /24 - it means all IPs 192.168.1.* are local).
    routers is your DCHP server, which is usually also the wifi router.
    domain_name_servers is most likely the same as your routers IP address. Add more by separating additional values with a space ( etc.) I also enabled option ntp_servers by removing the hash (#) from the beginning of the line.

  12. Login again using the fixed IP address

    $ ssh pi@
  13. Turn off wifi power management (sleep mode)

    Add this to file /etc/network/interfaces to turn off wifi (wlan0) power management:

    allow-hotplug wlan0
    iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
    wireless-power off


    You can check if the power management is on or off with either of these two:

    $ iwconfig 
    # displays among other things "Power Management:off"
    $ iw wlan0 get power_save 
    Power save: off
    # Turn off until the next reboot with
    $ iw wlan0 set power_save off
  14. Update Raspberry Pi hostname

    $ sudo nano /etc/hostname
    # update also hosts file to point the new hostname to localhost IP
    $ sudo nano /etc/hosts
    # replace old hostname on this line               raspberrypi
    # with your new one               homeraspi 

    You may want to update also your own laptop's /etc/hosts file with this record (add it to the end of the file).

    # on your laptop
    $ sudo nano /etc/hosts            yourhomeraspi
  15. Don't forget to change the password for pi user account!

  16. Put your SSH key to Raspberry Pi's pi user's account

    Now you can login using without your password, which is not just faster to connect to Raspberry Pi but also safer.

    First create the .ssh folder in Raspberry Pi:

    mkdir /home/pi/.ssh

    Assuming your SSH key is in file copy it from your laptop to Raspberry Pi:

    # on your laptop
    scp ~/.ssh/ pi@yourhomeraspi:/home/pi/.ssh/ 
    # On Raspberry Pi
    cd /home/pi/.ssh
    cat > authorized_keys
  17. Update all packages

    sudo apt update
    sudo apt upgrade
    sudo apt autoremove
  18. Reboot Raspberry Pi

    sudo reboot


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