2020-12-22 23:24:25 +01:00

2.2 KiB


This script modifies a Raspberry Pi OS image to enable SSH at boot. For security reasons, SSH is disabled.


If you are using Raspberry Pi OS (previously called Raspbian), at first startup you cannot connect directly via SSH to your Raspberry Pi because the SSH daemon (sshd) is not started. If you want to understand why this choice was made, it's over there:

Two choices are available to you. You have a HDMI cable that fits your Raspberry Pi and a keyboard. You log in with the user pi and password raspberry, and you execute the following command.

sudo systemctl enable --now sshd.service

Otherwise you modify the image of the Raspberry Pi OS by adding an empty file called ssh in the first partition and the system will understand that it must start the SSH daemon at boot.

This script allows you to do this second option very quickly.



This script can run on any GNU/Linux machine and uses standard commands. Normally all of them are already installed on your system.

Basically, only the superuser can mount filesystems, so it is necessary to run this script with root rights.


As soon as you have downloaded ( the version that suits your needs and unzipped it, you can do the following.

curl -Lo ssh-at-boot -sSf
chmod +x ssh-at-boot
sudo ./ssh-at-boot /path/to/raspberry-pi-os.img

If all goes well, the message File created. appears. You can now copy as you are used to do the image to the SD card and enjoy life.


Suppose you are in a hurry and you don't want to use the method mentioned above. You can do the following. This example assumes that you have already downloaded and unzipped the Raspberry Pi OS image.

Be careful. It is a practice that I strongly advise against. Running a script without even checking it is a bad practice. You know very well what I'm talking about.

curl -sSf | sudo bash -s -- 2020-12-02-raspios-buster-armhf-lite.img
File created.