Search code examples
raspberry-piraspbian

Configure raspberry pi wifi by writing to micro SD card


I have a raspberry pi but no external keyboard, mouse or ethernet cable to set it up - but I do have micro-sd card reader. Is there a way for me to just write my wireless internet config straight to the micro-sd card so the raspberry pi will be able to connect to the wifi, and then allow me to ssh in?

The micro-sd card already has Raspbian installed on it.


Solution

  • Sure.

    • Put the card in a drive and mount it.
    • Go to the partition called boot.

    Create an empty file called ssh just using:

    touch ssh            # Works in Linux/macOS
    type NUL >> ssh      # Works in Windows
    

    Create a file called wpa_supplicant.conf with your WiFi settings - be very sure that Windows hasn't added any .txt extension:

    country=US
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    
    network={
        ssid="NETWORK-NAME"
        psk="NETWORK-PASSWORD"
    }
    

    Once it works, and you can ssh successfully into the Raspberry Pi, be sure to run:

    sudo raspi-config
    

    and permanently enable ssh for subsequent reboots.