DEV Community

Hedy
Hedy

Posted on

How to connect to WiFi and turn on VNC on Raspberry Pi without mointor?

Here’s a clean, headless way to get a Raspberry Pi on Wi-Fi and enable VNC—no monitor needed.

What you’ll need

  • A flashed micro-SD with Raspberry Pi OS (Desktop is easiest for VNC).
  • Your Wi-Fi SSID, password, and country code (e.g., US/DE/CN).
  • Another computer on the same network (to SSH in once).

Method 1 (recommended): Use Raspberry Pi Imager’s advanced options

  1. Open Raspberry Pi Imager → choose OS (Raspberry Pi OS (32-bit)) and your SD card.

  2. Click the gear (advanced):

  • Set hostname (e.g., raspberrypi).
  • Set username/password (no default user anymore).
  • Enable SSH (use password or key).
  • Set Wi-Fi SSID, password, country.
  1. Write the card → insert in Pi → power it.

  2. Find it on the network: try ssh @raspberrypi.local or use the router’s DHCP list.

  3. Enable VNC via SSH:

sudo raspi-config nonint do_vnc 0
sudo systemctl enable --now vncserver-x11-serviced.service
Enter fullscreen mode Exit fullscreen mode

If you installed Lite (no desktop), add VNC + desktop first:

sudo apt update
sudo apt install -y realvnc-vnc-server raspberrypi-ui-mods
sudo systemctl set-default graphical.target
sudo reboot
Enter fullscreen mode Exit fullscreen mode
  1. On your PC, install RealVNC Viewer, connect to raspberrypi.local (or the Pi’s IP).

Method 2: Manual “boot partition” setup (if you can’t use Imager’s gear)

  1. After flashing, open the SD card’s boot volume on your computer.

  2. Create a file wpa_supplicant.conf (UTF-8, Unix line endings) with:

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
  ssid="YourWiFi"
  psk="YourPassword"
  scan_ssid=1
}
Enter fullscreen mode Exit fullscreen mode

(Change country, ssid, psk. Keep quotes.)

  1. Create an empty file named ssh (no extension) to enable SSH.

  2. (For newer OS builds) create a user non-interactively: add a file userconf containing
    username:encryptedpassword
    You can generate the encrypted password on Linux/macOS:
    openssl passwd -6 'yourpassword'

  3. Eject the card → boot the Pi.

  4. SSH in: ssh @raspberrypi.local (or by IP).

  5. Enable/install VNC as in Method 1 step 5.

Quick tips & troubleshooting

  • 2.4 GHz vs 5 GHz: Older Pi Zero/3 might only see 2.4 GHz. Ensure your SSID is on 2.4 GHz if needed.
  • Wi-Fi country is required for some channels—set it correctly.
  • If raspberrypi.local doesn’t resolve on Windows, use the IP address (or install Bonjour/mDNS), e.g. ssh user@192.168.1.123.
  • Check Wi-Fi status: iwgetid, ifconfig -a, sudo rfkill list.
  • If you used Lite, you need a desktop for full VNC X11 sharing (see install commands above). For CLI-only remote desktop, consider SSH + tmux or X11Forwarding.

That’s it—flash, preconfigure Wi-Fi + SSH, boot, SSH in, enable VNC, and connect from RealVNC Viewer.

Top comments (0)