Headless Raspbian for Raspberry Pi

Add Ethernet and Wi-Fi settings.


It becomes a daunting task to manually edit the files on an SD card for changing your Raspberry Pi’s Wi-Fi and network settings in the absence of a Monitor, Keyboard and Mouse.


I saw in a meetup that people were struggling to configure their Pi’s with the Wi-Fi name and password provided by the team in the venue as there were limited number of monitors available to graphically add them. No network means no SSH.


This tool here can make your life easy by asking you all the Ethernet and Wi-Fi details and configuring your SD Card having Raspbian Image with the given details. The steps are as follows:


git clone https://github.com/glowingthumb/RaspImgConfig

If you already have your SD card ready with the latest Raspbian OS, just run the script as Superuser:

Point to the SD Card:

If you have multiple SD Cards, select the targeted SD card:

Fill out your Ethernet settings, I am not showing all the steps, you just have to press Enter and move forward. At the end you have to press ‘Y’ to confirm:

The next step is the most interesting one. If your laptop is connected to a Wi-Fi hotspot, the script automatically detects that and assumes that you want to connect your Raspberry Pi with the same Wi-Fi hotspot and adds it as the default selection. Otherwise you can select Wi-Fi name from the list and write it manually or write any other name even if is not in the list. Just press Return to select the Wi-Fi to which your laptop is connected:

Now its time to type in the Wi-FI password:

Confirm your Wi-Fi setting. As soon as you confirm, all your settings will be saved in the SD card:

Now you can take out you SD card, plug it into your Pi and wait for it to boot up. If you have a WiFi dongle connected, your Pi will automatically get connected to the Wi-Fi hotspot.

 

SSH to your Pi with a single command without knowing it’s IP address.

You can use the –connect option to connect using SSH from your terminal. As you can see it takes a few minutes for your Pi to boot up and start the SSH server. Use the Raspbian default password-“raspberry” to login:

 

Limitations
This script only works in Linux. I have tested it on Ubuntu with Raspbian Wheezy and Jessie. Unfortunately the Linux tools options which I have used in the script such as “fdisk –output” and several such options are not present in iOS. This script will not work in MacBooks.

I wold be more than happy if someone could make this script work on iOS and other platforms as well. The code is in: https://github.com/glowingthumb/RaspImgConfig

1 comment on “Headless Raspbian for Raspberry Pi”

  1. Abhishek Kumar Reply

    Hello Subhajit,

    Is it possible to use your tool in windows operating system using Cygwin?

    -Abhishek

Leave A Reply

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

YouTube
LinkedIn
SOCIALICON