In this quick guide, we will walk you through the process of how you can enable SSH when your Raspberry Pi boots.
Before you continue any further, please note that this tutorial will be assuming that you are using Raspberry Pi OS. The specific functionality we are using may be present in other operating systems, but we are focusing on this particular OS for this guide.
If you have ever wanted to enable SSH on boot on your Raspberry Pi, you are in luck as the process is very straightforward.
During the boot process for Raspberry Pi OS, it checks the “
boot” partition for various files. One of the files that it looks for is called “
ssh“. If it detects this file, it will automatically prepare and set up SSH on your Raspberry Pi.
We use this process when we want to set up a headless Raspberry Pi as it is the easiest and fastest way of enabling SSH on a Raspberry Pi.
The reason that SSH is disabled by default all comes down to ensuring the security of your device. As Raspberry Pi OS’s default password is easy to find, anyone on your network could gain access to your Pi after enabling SSH.
After enabling SSH, be sure to follow our guide on improving your Raspberry Pi’s security.
For this guide on how to enable SSH on boot on a Raspberry Pi, we used the following equipment.
Enable SSH on Boot on a Raspberry Pi
As mentioned earlier in this guide, enabling SSH to start on boot on the Raspberry Pi is a straightforward process that will only take you a couple of minutes.
The easiest time to do this is when you first flash Raspberry Pi OS to your SD Card or USB drive.
1. When you insert your SD card into a computer, you will gain access to the partitions that have been written to it during the flashing process.
The partition you need to open up is the one that is called “
boot“. This partition is where files related to the boot process of the Raspberry Pi are stored.
Within this partition is where we will create the file we need to enable the SSH service.
If you are doing this directly on your Raspberry Pi, you can use the cd command to change into this directory.
2. Once you have this partition opened on your device, you can now create the needed file.
This file needs to be called “
ssh” with no file extension. The file does not need to contain any actual data.
If you are using Windows, you can create this file by right-clicking in the folder, selecting “
New“, then “
New Text Document“, then renaming that file to “
ssh“. Make sure this file does not have an extension.
If this guide is being done on the Raspberry Pi itself, you can create this empty file by running the following command within the terminal.
sudo touch ssh
3. After creating the “
ssh” file within the “
boot” partition, you can now take the SD card out of your device and place it in your Raspberry Pi.
Now when your Raspberry Pi boots, it will enable and configure SSH to run on your device. Enabling this protocol will allow you to control your device remotely.
If you are doing this on the Pi itself, you can restart your device by running the following command.
4. Now that you have SSH enabled on your Raspberry Pi, we highly recommend that you go through our guide on improving the security of your Raspberry Pi.
As SSH is a protocol that allows someone to remote access a device, it is crucial that you, at the very least, change the default password of your device.
This guide will have shown you how you can enable SSH on the boot-up of the Raspberry Pi. It is a super easy method that only needs you to create a single empty file on the boot partition of your SD card.
SSH is an excellent tool for remotely managing your Raspberry Pi. It is also extremely useful when you don’t have a monitor, keyboard, or mouse for your Pi.
Once you have SSH enabled at boot on your Raspberry Pi, be sure to try out some of our many other great Pi projects and guides.
If you have run into any issues getting SSH to enable on boot, please leave a comment below.
Alternatively, you can set it in the latest Raspberry Pi Imager by hitting Ctrl+Shift+X and enabling ssh.