RaspberryPi headless setup

Photo by Stan Slade on Unsplash

RaspberryPi headless setup

Step 1: Boot OS

  • Download the OS from here

  • Download the etcher from here

  • Extract the image file from the downloaded OS

  • Plug your sd card into the system

  • Open the etcher, select the image, and your sd card

  • Press the flash button

  • Congo!! you have successfully booted the os on the sd card.

Step 2: Turn on the pie

Now we need to create two files in the raspberry pi boot folder inside the sd card. First, create a file named ssh (without any extension) using the command

touch ssh

Create a second file named wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant
update_config=1
country=<Insert country code here> # IN (INDIA)

network={
 ssid="<Name of your WiFi>"
 psk="<Password for your WiFi>"
}

Now insert the sd card into your raspberry pi and power it on.

Step 3: Find the IP

Now we need to find the IP address of raspberry

  • Install Nmap using this command sudo apt install nmap

  • Now get your system IP address using the command ifconfig.

  • Now scan your whole network using the command nmap -sn <your ip address>/24

  • Note: replace your IP address's last digit with 0. For example: 192.168.41.16 with 192.168.41.0

  • Now you need to manually identify the IP address of your raspberry.

  • To verify the IP we need to ssh into the raspberry pi with each IP.

Step 4: SSH to pie

  • For each IP ssh using the command ssh pi@<ip address>

  • The default password is raspberry

  • Now you have successfully logged in to your raspberry pi

Step 5: Enable root user

  • Now you are logged in as user pi, which is the default user

  • Enable the root user to log in using ssh

  • First, log in with the pi user using the default password which is raspberry

  • Now write this command to login as root sudo su

  • Now edit the file /etc/ssh/sshd_config using command nano /etc/ssh/sshd_config

  • Change the text #PermitRootLogin without-password to PermitRootLogin yes

  • Now save and exit the file

  • Now run the command to restart the ssh service /etc/init.d/ssh restart

  • Now set your root password using the command passwd root

  • Now enter your password.

  • Once you have successfully set the password, you can log in to raspberry as the root user using the command ssh root@<raspberry ip address>

Did you find this article valuable?

Support Nitin Raturi by becoming a sponsor. Any amount is appreciated!