The following steps will work in any Raspberry Pi with Raspbian (now called Raspberry Pi OS), regardless of the model.

Use the installation tool to write the operating system in the memory card. Follow the official website link for downloads [Link].

Create an empty file called ssh inside the boot partition.

sudo touch ssh

Then add the wifi configuration inside the rootfs partition:

sudo nano etc/wpa_supplicant/wpa_supplicant.conf

Add these lines at the end of the file, replacing the SSID and PASSWORD (you can add more than these lines more than once to be able to connect to more networks):

network={
  ssid="SSID"
  psk="PASSWORD"
}

Run the Raspberry Pi with the newly created image with SSH and WIFI configured. It also comes with the default hostname “raspberrypi“, you probably try to connect using the hostname.

If the hostname did not work, find out the IP obtained by your RPi:

sudo arp-scan ‐‐interface=wlan0 ‐‐localnet

Replace wlan0 with your own adapter name.

In my case, it got the IP: 192.168.2.102, so let’s access it via SSH:

ssh pi@192.168.2.102

Remember, the default password is “raspberry“.

sudo raspi-config

In the Rasp-Config > Interfacing Options > VNC > Yes.

Now you can use any VNC viewer to access your RPi. I recommend the RealVNC [Link].

Use the IP to connect via VNC, as you did with the SSH.

Recommendations:

  • Install UFW;
  • Allow ports 22 (SSH);
  • Allow port 5900 (VNC);
  • Enable the firewall to run at the startup;
  • In case your RPi does not connect to the WIFI, it is also a good idea to be able to connect to it via Bluetooth Network (PAN), read the following post [Read It].