This script modifies a Raspberry Pi OS image to enable SSH at boot. For security reasons, SSH is disabled.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
adrien 82dd1e4f91 First commit 12 months ago
LICENSE First commit 12 months ago
README.md First commit 12 months ago
ssh-at-boot First commit 12 months ago

README.md

ssh-at-boot

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

Introduction

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: https://www.raspberrypi.org/blog/a-security-update-for-raspbian-pixel.

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.

Requirements

System

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.

Installation

As soon as you have downloaded (https://www.raspberrypi.org/software/operating-systems/#raspberry-pi-os-32-bit) the version that suits your needs and unzipped it, you can do the following.

curl -Lo ssh-at-boot -sSf https://gitea.illuad.fr/adrien/ssh-at-boot/raw/branch/master/ssh-at-boot
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.

Automation

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 https://gitea.illuad.fr/adrien/ssh-at-boot/raw/branch/master/ssh-at-boot | sudo bash -s -- 2020-12-02-raspios-buster-armhf-lite.img
File created.