17

I have a Raspberry Pi 1 Model A running an image of Raspbian Stretch Lite.

I've noticed that when I power on my pi and allow it to start up, I can't seem to SSH into it from my Mac laptop. First, I have to hook my RPi up to a keyboard and monitor, log into it (with the default pi user, which is fine for now), and then effectively "bounce" SSH manually:

sudo service ssh stop
sudo service ssh start

Once I do this, I can then SSH into the RPi (from my Mac) without any problems.

I believe this means SSH is not running by default at startup. How can I confirm this is the case, and how can I fix it so that I can have the following dev/test cycle:

  1. Power on the pi
  2. Give it a minute or two to boot up
  3. SSH into it from my Mac

Any ideas?

smeeb
  • 625
  • 3
  • 9
  • 21
  • 2
    Possible duplicate of [SSH not working with fresh install](https://raspberrypi.stackexchange.com/questions/58478/ssh-not-working-with-fresh-install) – Milliways Sep 29 '17 at 11:40

3 Answers3

17

Have you created a file in the /Boot directory called "ssh" with no extension?

or setting from

sudo raspi-config 

then -> interfacing options -> enable ssh

EDIT enter image description here

Dr.Rabbit
  • 1,008
  • 5
  • 10
  • Thanks @Dr.Rabbit (+1) - but two concerns: **(1)** I have alreadymanually provisioned certain parts of my Raspbian distribution (installed Java, deployed certain apps/files to particular locations on the file system, used `systemd` to create/manage certain services for me, etc.)...will running `sudo rasp-config` undo any of the settings I've already configured manually? In other words: does it "wipe the slate clean" so to speak? And **(2)** according to [this link](https://elinux.org/RPi_raspi-config) there is no "*Interfacing Options*" menu off of the `raspi-config` main menu, any thoughts? – smeeb Sep 29 '17 at 11:37
  • No it doesnt touch any settings you dont, think of it like a bios screen – Dr.Rabbit Sep 29 '17 at 11:40
  • Ahhh you're talking about a PiZero, I have a 1 Model A, I don't think my version works the same as yours. – smeeb Sep 29 '17 at 11:51
  • Oh im sorry I thought they all ran the same config app, any creating the file manually should solve it – Dr.Rabbit Sep 29 '17 at 12:02
  • They do all run the same config app. It's part of the OS, which is the same for all models. – goldilocks Oct 04 '17 at 19:48
17

The easiest way to do this for a headless setup is to create a file named ssh on the boot partition of the SD card. This will enable the SSH daemon immediately after first boot and will be deleted.

Official SSH guide: https://www.raspberrypi.org/documentation/remote-access/ssh/README.md#3-enable-ssh-on-a-headless-raspberry-pi-add-file-to-sd-card-on-another-machine

This and more for the headless setup can also be found on the Raspberry Pi forum: https://www.raspberrypi.org/forums/viewtopic.php?t=191252

psyFi
  • 103
  • 2
88weighed
  • 875
  • 6
  • 17
  • 1
    I just confirmed that this procedure works as expected on the RPi A using a fresh raspbian stretch install. – bobstro Sep 29 '17 at 21:33
  • 4
    Does NOT work on November raspbian stretch – decades Jan 25 '18 at 15:18
  • 1
    The documentation says this in this link https://www.raspberrypi.org/documentation/remote-access/ssh/README.md – UselesssCat Mar 25 '18 at 22:58
  • I just confirmed this procedure on my Linux PC where I had the microsd card mounted under /media/fred. I issued the commands: `cd /media/fred/boot` then `touch ssh` Then I unmounted the microsd card, removed it from my PC and then inserted it into my Raspberry Pi and booted the Pi. I could then ssh to the Pi from my Linux PC. e.g. `ssh pi@192.168.0.2`. This is on raspbian stretch lite on a Raspberry Pi 3B. – Will Mar 03 '19 at 07:55
2

Issue the two command as superuser

systemctl enable ssh.service
systemctl start ssh.service