Enable SSH server sshd on raspbian

In raspbian, theres a systemd service sshswitch.service that checks whether a certain file exists or not.

Description=Turn on SSH if /boot/ssh is present

ExecStart=/bin/sh -c "update-rc.d ssh enable && invoke-rc.d ssh start && rm -f /boot/ssh ; rm -f /boot/ssh.txt"


This means that to enable the sshd.service on a fresh install of raspbian you can create an empty file at /boot/ssh.

You can do this without power the Pi, by, for example:

# mkdir -p /mnt/boot
# mount /dev/mmcblk0p1 /mnt/boot
# touch /mnt/boot/ssh
$ sync
# umount /mnt/boot

And the sshd should be running on the next boot.