2022年9月6日 星期二

[rapi, headless] How to connect your Raspberry PI at the first time boot after flash the image

How to connect your Raspeberry PI at the first time boot after flash the image

井民全, Jing, mqjing@gmail.com

This document show you how to wirelessly ssh connect to your Raspberry PI that without the monotor and keyboard for the first time boot after downloaded the image. Briefly, In order to configure the WI-FI WPA, you should mount the SD card to your host, create the wpa_supplicant.conf on the boot partition, enable the ssh function and put it back to the Raspberry Pi for boot system. Wait a seconds, try to use arp-scan to scan the subnet to find out the raspberry PI IP. Now, you can get access to the Pi. Here is the quick guide.

 

1. Raspberry Pi Imager

https://www.raspberrypi.com/software/

 

2. Command Line

2.1. Quick Guide

Catgory

l1

Item

Note

Install OS, assign IP (DHCP)

headless setup

Raspberry Pi Imager

https://www.raspberrypi.org/downloads/

Install OS, assign IP (DHCP)

headless setup

enable ssh

[at the boot partition]

touch ssh

Install OS, assign IP (DHCP)

headless setup

enable wi-fi

[at boot partition]

touch wpa_supplicant.conf



country=us

update_config=1

ctrl_interface=/var/run/wpa_supplicant


network={

 scan_ssid=1

 ssid="MyNetworkSSID"

 psk="Pa55w0rd1234"

}


Ref:

https://www.raspberrypi-spy.co.uk/2017/04/manually-setting-up-pi-wifi-using-wpa_supplicant-conf/

Install OS, assign IP (DHCP)

headless setup

get ip

Linux

[host] sudo apt install arp-scan

[host] sudo arp-scan - I ens33 --localnet | grep pi


Windows

[host] arp -d

[host] arp -a | find "b8-27-eb"


Where "b8-27-eb" is the Raspberry Pi Foundation.

OLD

[host] sudo apt install nmap

[host] nmap -sn 192.168.1.0/24

Install OS, assign IP (DHCP)

headless setup

first login

ssh pi@192.168.1.105

Install OS, assign IP (DHCP)

headless setup

old passwd

u:pi

p:raspberry

Install OS, assign IP (DHCP)

headless setup

passwd, setup

[remote] sudo passwd 1234

 

2.2. Detal Procedure

Step 1: Enable ssh

cd to the boot device

touch ssh

 

Step 2: Setup Wirlesss WPA 

vi wpa_supplicant.conf

 

File: wpa_upplicant.conf

country=us

update_config=1

ctrl_interface=/var/run/wpa_supplicant


network={

 scan_ssid=1

 ssid="MyNetworkSSID"

 psk="Pa55w0rd1234"

}

 

If you are in Windows, plase notice the EOL conversion.

 

Step 3: Boot the system



2.3. Scan the Raspberry PI IP

2.3.1. Linux

Command

sudo arp-scan - I ens33 --localnet

 

Where the ens33 is my nic name, you can find yours by using ip a command. See the detail info.

E.g.

Or you can use following instructions to find the PI's IP.

sudo arp-scan - I ens33 --localnet | grep pi



2.3.2. Windows

Command

arp -d  :: Delete ARP entry at first

arp -a  :: List ARP entry

 

E.g.

Power on the Raspeberry PI

Run the command: 

arp -a

 

Look-up the Mac-add

https://macvendors.com/

Or

arp -a | find "b8-27-eb"

 

3. Verification




4. References

  1. https://foolsvilla.blogspot.com/2020/03/how-to-set-static-ip-address-for.html

  2. https://learn.sparkfun.com/tutorials/headless-raspberry-pi-setup/wifi-with-dhcp#:~:text=Enable%20WiFi,wpa_supplicant%2F%20directory%20in%20the%20filesystem.

  3.