LonelyPixel
Posts: 26
Joined: Fri Apr 18, 2014 2:19 pm

Enable SSH before first contact

Thu Apr 05, 2018 10:29 am

Hi,

I've bought a new Raspberry Pi 3 B+ for use with RasPBX which failed to boot. So I tried with the official Raspbian image which did boot but that's all it does. I need remote access to it to do anything with it. Unfortunately, SSH access is now disabled by default. Trying to connect to it with PuTTY says "Connection refused". The other RasPi (gen 1) in the network is still accessible. I don't have a monitor or keyboard available. All I have is a USB power supply and a LAN cable. This works just fine with all other Linux devices or servers I work with. But the new Raspberry system doesn't provide this functionality.

How can I enable the SSH server without interactive access? Can I write something on the SD card (the first partition because Windows can't use the second partition) to accomplish this?

MaxVMH
Posts: 114
Joined: Mon Mar 19, 2018 1:26 pm

Re: Enable SSH before first contact

Thu Apr 05, 2018 10:32 am

Create an empty file with the name 'SSH' and put it on the BOOT partition.

(FYI: 'SSH.TXT' is also a valid name and it doesn't necessarily have to be an empty file.)

Let us know how that works out for you ;)
Webserver stack: 2x Pi 3B | 1x Pi 3B+ ||| Pi Zero W for fooling around

Working on a soccer prediction web app:
https://github.com/MaxVMH/mijnscore
Attempt at writing up-to-date tutorials on making a Raspberry Pi webserver:
http://blog.mijnscore.be/

User avatar
B.Goode
Posts: 13217
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Enable SSH before first contact

Thu Apr 05, 2018 10:38 am

How can I enable the SSH server without interactive access? Can I write something on the SD card (the first partition because Windows can't use the second partition) to accomplish this?
As @maxvmh has said: Yes.

And here is the documentation from the Raspberry Pi Foundation:
3. Enable SSH on a headless Raspberry Pi (add file to SD card on another machine)
For headless setup, SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer. When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is deleted. The content of the file does not matter; it could contain text, or nothing at all.

If you have loaded Raspbian onto a blank SD card, you will have two partitions. The first one, which is the smaller one, is the boot partition. Place the file into this one.
That's from:
https://www.raspberrypi.org/documentati ... /README.md

LonelyPixel
Posts: 26
Joined: Fri Apr 18, 2014 2:19 pm

Re: Enable SSH before first contact

Thu Apr 05, 2018 10:40 am

Oh right, sorry for the stupid question. I must have misread that part of the page. Yes, that works. Thank you!

MaxVMH
Posts: 114
Joined: Mon Mar 19, 2018 1:26 pm

Re: Enable SSH before first contact

Thu Apr 05, 2018 10:45 am

LonelyPixel wrote:
Thu Apr 05, 2018 10:40 am
Oh right, sorry for the stupid question. I must have misread that part of the page. Yes, that works. Thank you!
No problem, glad to be of help 8-)
Webserver stack: 2x Pi 3B | 1x Pi 3B+ ||| Pi Zero W for fooling around

Working on a soccer prediction web app:
https://github.com/MaxVMH/mijnscore
Attempt at writing up-to-date tutorials on making a Raspberry Pi webserver:
http://blog.mijnscore.be/

Return to “Troubleshooting”