43

I'm following a number of tutorials that explain how to setup an SD card that boots automatically enabling ssh in the process. I'm doing this as I only have a laptop and no spare keyboard, screen, etc. My problem is I cannot find the boot_enable_ssh.rc file.

All of the tutorials I've read describe using dd (so doing this using Unix (Ubuntu)) to write the .img file to the SD card. Done like this:

sudo dd bs=1M if=/path/to/2012-08-16-wheezy-raspbian.img of=/dev/sdb

This completes successfully; the next step is to copy the file

mv  /boot/boot_enable_ssh.rc  /boot/boot.rc

boot_enable_ssh.rc is missing.

I've run the dd action using the two most recent image files from the RPi official site - 2012-07-15-wheezy-raspbian.img - 2012-08-16-wheezy-raspbian.img

but for both, there is no /boot/boot_enable_ssh.rc file.

I've also tried searching with find (sudo find /media/ -name boot_enable_ssh.rc). Still with no success.

Am I doing something wrong is there another way to get ssh going?

Ghanima
  • 15,855
  • 15
  • 61
  • 119
Noel Evans
  • 535
  • 1
  • 5
  • 9

6 Answers6

52

Although Raspbian used to enable ssh by default, from December 2016 it no longer does so. While there is still no boot_enable_ssh.rc file as the OP requested in 2012, ssh can be enabled on first boot by creating a file called “ssh” in /boot. As /boot can be written to by any OS that understands SD cards, this extra step is easily done on first installation. It does not need to be done again with the same card image. You can also enable it through raspi-config as before.

The Raspberry Pi Foundation chose to do this as enabling ssh by default and having a well-known user name/password combination is a security risk.

scruss
  • 9,068
  • 1
  • 24
  • 35
  • The officially downloadable Raspbian “wheezy” image starts the sshd per default. – KARASZI István Dec 14 '12 at 19:57
  • 1
    “jessie” does not start sshd anymore by default. – Simon A. Eugster Dec 02 '16 at 21:40
  • 2
    yup, updated my answer to match reality. It did pretty well to be true for more than four years … – scruss Dec 02 '16 at 22:46
  • Thanks for the update – just wanted to add the same link :) – Simon A. Eugster Dec 03 '16 at 21:29
  • Yes! To clarify, /boot refers the partition called boot, no the directory boot in the raspbian ext4 partition – Mikel Mar 08 '17 at 18:53
  • There isn't a directory boot in the raspbian ext4 partition. Everything appears under / with Linux, even if /boot is the filesystem /dev/mmcblk0p1. – scruss Mar 08 '17 at 19:06
  • 1
    in other words to enable it run touch /boot/ssh then reboot your raspberry pi. – Tono Nam Apr 03 '18 at 20:38
  • that's one way of doing it, @TonoNam. There are many others. – scruss Apr 03 '18 at 23:11
  • One could modify the image before writing it to the card by mounting it: $ sudo mount -o loop,offset=4194304 2018-04-18-raspbian-stretch-lite.img /mnt/raspbian and then $ sudo touch /mnt/raspbian/ssh. After that (and possibly some more modifications), one could write the modified image to the SD card. – HarryH Jun 19 '18 at 07:30
4

In raspian, if the above suggestions do not work (all though the "mv /boot/boot_enable_ssh.rc /boot/boot.rc" should make it work on the next boot, and there after), the more manual way is to run

sudo raspi-config

and then in the config under advanced options - there is a start ssh option which will start the service.

mike
  • 41
  • 1
3

Regardless if ssh is enabled by default in a particular distribution, the:

mv /boot/boot_enable_ssh.rc /boot/boot.rc

line must be run on the Raspberry Pi for it to work as expected. If you're working from a different computer, you should first mount the SD-card in your filesystem, then operate on .rc files in this mounted card. I don't have access to a proper box now to verify exact commands, but it would look something like:

mkdir ~/sdcard
sudo mount /dev/sdb ~/sdcard
mv ~/sdcard/boot_enable_ssh.rc ~/sdcard/boot/boot.rc
umount ~/sdcard
akavel
  • 1,216
  • 3
  • 12
  • 15
0

For anyone who got a RPi with NOOBS preinstalled on the SD like me and encounters this problem:

SSH seems to be disabled on default with NOOBS. I had to format the SD-card and put the Raspbian image on there before booting up the RPi for the first time.

0

Even though Rasbian uses systemd (A hydra monster of a program that goes against the Unix philosophy of do one thing and do it well.) You can use the "update-rc.d" command to add the System-V style ssh daemon init script to your system startup using the following command:

sudo update-rc.d ssh enable

Clear as mud?

-1

Here's how to do a headless Raspbian install on your Pi. Download Raspbian Image. Head on over here to grab a copy of the Raspbian image. ... Write Image to SD Card. Write the image to SD card. ... Add “SSH” File to the SD Card Root. ... Boot your Pi. ... Find your Pi's IP Address. ... SSH into your Pi. ... Configure your Pi

  • Wrong. You should add the empty file 'ssh' (small capitals, not large as you seem to indicate) to the /boot directory (which is on a separate partition). – HarryH Jun 19 '18 at 07:22
  • in the year 2k22 its so easy. go to https://www.raspberrypi.com/software/ download the raspberry imager. Format your SD card, start the raspberry imager. Choose your sd and click on the gearwheel in the down right corner. click on "enable ssh" and pick User password authentication. Click Set username and password and set both. Then run the imager. Done :-) – Iskandir Nov 07 '22 at 19:29