Husband. Father. Software engineer. Ubuntu Linux user.
No keyboard, mouse, or monitor required! In this tutorial, I’ll show you how to ssh to a Raspberry Pi Zero W without ever using a keyboard, mouse, or monitor on the device itself. We’ll prepare the device to connect to your wireless network (even with a password) when it’s turned on for the first time – this process is known as “headless setup”.
When you buy a Raspberry Pi, the cost of all the little accessories you might need (like a way to connect a keyboard, mouse, and monitor to the micro-USB and micro-HDMI ports) can add up quickly. But do you really need all that? You don’t! It isn’t too hard to configure a Raspberry Pi Zero W to connect to a wireless network automatically when it boots, and then you can interact with it via SSH without ever connecting a monitor, keyboard, or mouse! (You’ll need another computer, of course.) To accomplish this, we’ll modify a couple things on the SD card after we’ve written the image but before putting it in the Pi.
On the boot partition, create a text file named wpa_supplicant.conf
(no
.txt
!) with the following contents. This will configure the wifi when the
device boots. (Change the ssid and psk to your network name and password.)
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="MyWiFiNetwork"
psk="aVeryStrongPassword"
key_mgmt=WPA-PSK
}
Warning!
The Pi Zero W doesn't support 5GHz networks. You'll need to use a 2.4GHz network with your Pi.
ssh
(no file
extension!) on the boot partition. As long as this file exists, ssh will
be enabled when the device boots for the first time.192.168.0.10
, but it could be different.ssh
pi@192.168.x.x
(using the IP you found in the previous step). pi
is the
username and raspberry
is the default password.pi
as the
username and raspberry
as the password.Done! Now that you’re connected to the Pi via SSH, you can run any commands
you want to. You might start with sudo apt-get update && sudo apt-get upgrade
to make sure the system’s up to date. From there, you can play around as much as
you want in the Raspbian Linux environment (based on Debian/Ubuntu), or you can
install any additional software needed for your project.
I hope this helped you get started with your Raspberry Pi, and maybe saved you a few dollars on accessories you don’t need to buy!
This is part 1 of a 2-part series exploring the Raspberry-Pi Zero.
👋 Hi, I'm Mike! I'm a husband, I'm a father, and I'm a senior software engineer at Strava. I use Ubuntu Linux daily at work and at home. And I enjoy writing about Linux, open source, programming, 3D printing, tech, and other random topics. I'd love to have you follow me on X or LinkedIn to show your support and see when I write new content!
I run this blog in my spare time. There's no need to pay to access any of the content on this site, but if you find my content useful and would like to show your support, buying me a coffee is a small gesture to let me know what you like and encourage me to write more great content!
You can also support me by visiting LinuxLaptopPrices.com, a website I run as a side project.