Enable ssh on a headless Raspberry Pi

Since version 2016-11-25 of Raspbian the ssh daemon is disabled by default (see the Raspbian release notes). But the Raspbian documentation on ssh describes a way how you can enable it again. You can do that before you even copy the image to an SD card and boot for the first time. This comes in handy especially when you run your Raspberry Pi without a monitor or keyboard attached (headless).

Here is what you need to do:

$ fdisk -l 2017-02-16-raspbian-jessie-lite.img
Disk 2017-02-16-raspbian-jessie-lite.img: 1,3 GiB, 1437597696 bytes, 2807808 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xdbcc7ab3

Device                               Boot  Start     End Sectors  Size Id Type
2017-02-16-raspbian-jessie-lite.img1        8192  137215  129024   63M  c W95 FAT32 (LBA)
2017-02-16-raspbian-jessie-lite.img2      137216 2807807 2670592  1,3G 83 Linux
$ mkdir mnt
$ sudo mount -v -o offset=4194304 -t vfat 2017-02-16-raspbian-jessie-lite.img mnt
$ sudo touch mnt/ssh
$ sudo umount mnt