Skip to main content

How to Set Up a Headless Raspberry Pi, Without Ever Attaching a Monitor

Raspberry Pis are so convenient because they're inexpensive and small, but connecting one to its own monitor, keyboard and mouse requires a lot more space and money. If you're just trying to program on the Pi or use it to control electronics such as lights, motors and sensors, there's no need to connect it to a display or input devices because you can control the system remotely, using a VNC or SSH client on your main computer. We call this screenless install a  headless Raspberry Pi setup.

By default, the Raspberry Pi's official operating system, Raspberry Pi OS (formerly known as Raspbian), installs with all forms of remote access disabled. But the good news is that you don't need to connect to a monitor and keyboard in order to turn them on. By following the instructions below, you can create a headless Raspberry Pi that's ready for remote access before you boot it up for the very first time. If you have a monitor and keyboard on hand, you can also see our guide on How to Set Up a Raspberry Pi for the First Time.

Installing Raspberry Pi OS on Your microSD card

1. Insert a microSD card into your computer. Your card should be 8GB or larger (the lite version of Raspberry Pi OS will use less space). We have a list of the best microSD cards for Raspberry Pi to help you choose one that optimizes performance.

2. Download, install and run Raspberry Pi Imager (opens in new tab)

3. Click the Choose OS button. A menu appears.

Raspberry Pi Imager

(Image credit: Tom's Hardware)

4. Select your OS. The best choice for most people is Raspberry Pi OS (32-bit). However, if you have a Pi 3 or 4, you can use the 64-bit version which is under "Pi OS (other). There are also other choices.

Choosing Pi OS 32-bit

(Image credit: Tom's Hardware)

5. Click Choose Storage and select your card from the menu. 

Choose storage

(Image credit: Tom's Hardware)

6. Click the settings button or hit CTRL + Shift + X to bring up the settings menu.

Click settings

(Image credit: Tom's Hardware)

A menu appears.

7. Toggle set hostname and change the hostname if you want your device to be named anything other than "raspberrypi." 

Set hostname

(Image credit: Tom's Hardware)

8. Toggle enable SSH to on and select "User password authentication." 

Enable SSH

(Image credit: Tom's Hardware)

9. Set a username and password for your Pi. Note that if you use the password "raspberry" with username "pi," you may get a warning message when you log in, recommending (but not forcing you) that you change the password.

set username and password

(Image credit: Tom's Hardware)

10. Set your Wi-Fi network's SSID, password and country. Then click Save. The country usually defaults to "GB" (Great Britain) so, if you are in the U.S., you will have to scroll down a really long way to get the country code you need. 

set wifi settings and save

(Image credit: Tom's Hardware)

11. Click Write and click Yes if asked whether you are sure you want to continue.

click write

(Image credit: Tom's Hardware)

The system will now take a few minutes to download the OS and write it to your card. 

Writing to card completed

(Image credit: Tom's Hardware)

When it's done, you can pop your card into a Raspberry Pi, boot it up, wait a few seconds for it to get onto the network and attempt to log in via SSH, provided that you're using a Wi-Fi network and both the Pi and your client PC are connected to it.

Editing Wi-Fi on a Prewritten Card

Let's say you already wrote a card, but forgot to enter the correct Wi-Fi credentials in Raspberry Pi Imager. Or perhaps you moved to a different Wi-Fi network. You can still change the Wi-Fi network, without attaching a screen and keyboard to the Pi.

To setup a Wi-Fi connection on your headless Raspberry Pi, open the microSD card on your PC. Then create a text file called wpa_supplicant.conf, and place it in the root directory of the microSD card. You will need the following text in the file.

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

network={
scan_ssid=1
ssid="your_wifi_ssid"
psk="your_wifi_password"
}

Change the country to "GB" for the UK or to another country code for a different country, and enter your actual SSID and password. Upon boot up, Raspberry Pi OS will log you into that network. However, if you're on a public Wi-Fi network that requires you to click "Ok" on a splash page before you get Internet, this method won't work.

Prefer to use Ethernet? If you plug your Raspberry Pi directly to a wired network, you should be able to access it by its name (raspberrypi or raspberrypi.local) without changing any other files.

Direct USB Connection (Pi Zero / Zero W Only)

My favorite way to connect is via a direct USB connection, plugging my Pi Zero W directly into a port on my PC. This method is great, because it works no matter where you are (even if there's no available Wi-Fi), and it provides both power and a connection to your Pi, over a single cable. However, you can only do this on a Pi Zero or Zero W.

1. Open the file config.txt in the root directory of the micro SD card, and add the line dtoverlay=dwc2 to the very bottom of the file and save.

2. Open cmdline.txt and add the text modules-load=dwc2,g_ether after the word rootwait, and save the file. There are no linebreaks in this file.

3. Download and install Bonjour Print Services (opens in new tab) from apple.com (if you have Windows). It seems strange that you would need an Apple program to access a Pi from Windows, but this helps your PC see the Pi. Ignore the name; you're not using this for printing.

4. Connect the micro USB cable to the port labeled "USB" on the Pi Zero. This will not work if you connect to the port labeled "PWR." However, the "USB" port will also supply power to your Pi, so you don't need to connect a dedicated power wire.

Direct Ethernet Connection

If your PC has a spare Ethernet port or you have an Ethernet-to-USB dongle, you can use a network cable to go directly from your Pi to your computer. Just make sure that you have Bonjour installed on your PC and SSH enabled on the Pi (see above). Then, you can just connect the two devices over Ethernet.

If you want the Raspberry Pi to get its Internet connection from your PC over the Ethernet port, you need to do the following in Windows 10 or 11:

1. Navigate to the Network Connections menu, which is part of the old-school Control Panel. You can get to this screen by going to Settings->Network & Internet->Wi-Fi and then clicking "Change Adapter Settings" on the right side of the screen. This works whether you are sharing an Internet connection that comes to your PC from Wi-Fi or from Ethernet.

2. Right-click on the adapter that's connected to the Internet, and select properties.

3. Enable "Allow other network users to connect" on the "Sharing" tab.

4. Select the Ethernet port that is connected to the Raspberry Pi from the "Home networking connection" menu, and click Ok.

Connecting to Your Pi via SSH

After you have the Pi connected to your network or directly to your PC, you'll need to establish an SSH connection.

1. Download and install Putty if you don't already have it. Putty is the leading SSH client for Windows.

2. Enter the hostname (by default raspberrypi or raspberrypi.local ) as the address you wish to connect to in Putty, and click Open. You usually need to add the .local if the Pi is directly connected to your PC via USB or Ethernet cable.

3. Click Ok if you get a security warning alert. It's not a problem.

4. Enter your username and password.

Now you're connected at the command prompt, but if you want to access the GUI, complete with a desktop and floating windows, you'll need to enable VNC.

Enabling and Connecting over VNC

1. Enter sudo raspi-config at the command prompt.

A configuration app opens.

2. Select Interfacing Options (number 5 on the list)

3. Select VNC (number 3 on the menu)

4. Select Yes. 

5. Hit Enter to acknowledge the VNC server is enabled.

6. Select Finish

On your PC:

1. Download, install and launch VNC Viewer.

2. Select New connection from the File menu.

3. Enter the host name (ex: raspberrypi.local) in the "VNC Server" field. If this does not work, try again without the .local in the name.

4. Click Ok.

5. Double-click on the connection icon to connect.


6. Click Ok if you are shown a security warning.

7. Enter the Pi's username and password when prompted. 


Your Raspberry Pi desktop will then appear in a window on your main computer's desktop. You'll be able to control everything from there.

Avram Piltch is Tom's Hardware's editor-in-chief. When he's not playing with the latest gadgets at work or putting on VR helmets at trade shows, you'll find him rooting his phone, taking apart his PC or coding plugins. With his technical knowledge and passion for testing, Avram developed many real-world benchmarks, including our laptop battery test.
  • HerbCSO
    This is all great, and I was able to set up my Pi headless using these instructions, so thanks for providing this. However I can't seem to be able to set the resolution on the VNC desktop any higher than what appears to be about 640x480 - any idea how I can crank that up a little? That's so 1990's... ;]
    Reply
  • janseta
    Hello,
    I think there is a little oversight in the "Headless Install" instructions on the Raspberry. Specifically in the "Direct Ethernet Connection" section.

    It describes that the Raspberry and the PC must be connected by a network cable. But you FORGET to say that it must be a crossover cable... (or do it with 2 network cables and an intermediate switch).

    It took me a couple of days and several reinstallations of the Raspian, so I leave this advice here for those who can take advantage of it.

    Greetings

    Translated with www.DeepL.com/Translator (free version)
    Reply
  • fsebbah
    Hello,
    I followed your tutorial and its great. I use a PI 4 8Go
    I installed this PI OS : 2020-08-20-raspios-buster-armhf.img
    Two remarks:
    One : In the Wifi properties, afetr i shared it, I activated the ssh port 22. I clicked on the parameter's button and I create a service and the name box, i give the name of my Latpo
    Second: The password is pi et not raspberry.
    Thanks for your tutorial,
    Franck
    Reply
  • Senile Otaku
    Apparently in the interim the Ubuntu rPi image no longer has a "pi" user. I looked in the /home directory and saw a "ubuntu" dir there, and confirmed the login name in /etc/passwd. Password of "ubuntu" (good guess) worked, as it immediately wanted to change the default password (I had already copied in my ssh key).
    Reply
  • fearless_fool
    My stumbling point:
    7. Write an empty text file named "ssh" (no file extension) to the root of the directory of the card.
    My Windows10 system doesn't know how to mount the SD card, presumably since it's EXT4 format (for Linux). How do the cool kids handle this step?
    Reply
  • fauxhausen
    A Windows 10 PC should see two drives, a boot drive and the SDHC which it can't mount. The boot drive will have the bootup files and that's where you drop the SSH file. My problem with the article is that I plan to have the Pi on the network to my router via ethernet, not direct ethernet to my pc.
    Reply
  • burtonrodman
    on Windows 10, the device may show up as a COM Port instead of RNDIS Gadget. If so, see this YouTube video for instructions to update the driver from official Microsoft source: (60) Installing Ethernet/RNDIS driver on Windows 10 to connect Raspberry PI via USB - YouTube
    Reply
  • galoAguirre
    hi, this worked like a charm! thanks so much!!

    although the raspberry pi imager program configured the ssh and wifi automatically,

    it did not properly download the OS image for me here in Ecuador, for some reason,

    everything else worked great, so simple!

    have agood one,

    Galo
    Reply
  • KruseLudington
    fauxhausen said:
    A Windows 10 PC should see two drives, a boot drive and the SDHC which it can't mount. The boot drive will have the bootup files and that's where you drop the SSH file. My problem with the article is that I plan to have the Pi on the network to my router via ethernet, not direct ethernet to my pc.
    Thanks for this - so did you just follow the directions as given and then connected the PI afterward to your network ()instead of the PC directly)? And as per the other comment - did you have to use a crossover cable? Thx in advance for your answers!
    Reply
  • Mnfzzz
    I just wanted to add for anyone following this guide - the pi/raspberry user is not part of Raspberry Pi by default and the Imager does not by default set up a username/password for headless setup. You will not be able to SSH using pi/raspberry if you follow the guide exactly. In the new imager, ideally, you have to click the settings gear, go to advanced options, and specify a username/password.

    I've had quite a bit of trouble with headless setup beyond that, but I'm fairly sure that's more to do with me than the imager or pi. Will be troubleshooting as soon as I can get a screen and then might update if I find anything useful.
    Reply