Kagetaze
Posts: 86
Joined: Sat Jan 24, 2015 12:01 pm

Enable SSH before first boot

Tue Dec 22, 2015 9:16 am

Hello everyone!

Bit of an odd question to you all, perhaps. I know (as I've done it a million times before) that when I downloaded and port Raspian to the RPI on the SD card that upon first boot, I go through the raspi-config (it shows up unasked)

Let's assume for scientific reasons that I currently have no access to a keyboard to go through this menu. Is there a way to activate SSH so that I can connect to it, then go through the menu through putty?

Thanks!

User avatar
bugsy_malone 666
Posts: 274
Joined: Mon Dec 17, 2012 10:50 pm
Location: Basingstoke UK

Re: Enable SSH before first boot

Tue Dec 22, 2015 9:19 am

Have you tried connecting to it through SSH?

I cant recall ever 'enabling' SSH as I think it must be enabled as standard.

Someone may have a more definitive answer, but try it, whats the worst that can happen?

fruitoftheloom
Posts: 19781
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: Enable SSH before first boot

Tue Dec 22, 2015 9:22 am

Kagetaze wrote:Hello everyone!

Bit of an odd question to you all, perhaps. I know (as I've done it a million times before) that when I downloaded and port Raspian to the RPI on the SD card that upon first boot, I go through the raspi-config (it shows up unasked)

Let's assume for scientific reasons that I currently have no access to a keyboard to go through this menu. Is there a way to activate SSH so that I can connect to it, then go through the menu through putty?

Thanks!
I do feel sorry for the people who write Documentation which is never read on the RPF WebSite Help Section :shock:

You can enable or disable the SSH server on your Raspberry Pi (it is enabled by default).

https://www.raspberrypi.org/documentation/remote-access which applies to a Raspbian install without NOOBS
adieu

My other Computer is an Asus CS10 ChromeBit running Chrome Operating System.
HP Envy 4500 Wireless Printer supported by HPLIP software in Raspbian Buster.
Raspberry Pi Model 2B v1.1

User avatar
hansotten
Posts: 324
Joined: Fri Jul 13, 2012 6:01 am
Contact: Website

Re: Enable SSH before first boot

Tue Dec 22, 2015 9:23 am

Kagetaze wrote:Hello everyone!

Bit of an odd question to you all, perhaps. I know (as I've done it a million times before) that when I downloaded and port Raspian to the RPI on the SD card that upon first boot, I go through the raspi-config (it shows up unasked)

Let's assume for scientific reasons that I currently have no access to a keyboard to go through this menu. Is there a way to activate SSH so that I can connect to it, then go through the menu through putty?

Thanks!
I do that all the time, no keyboard/display required . SSH is enabled at first boot.
http://duinorasp.hansotten.com for Raspberry Pi and Arduino and ESP8266
http://retro.hansotten.nl for retrocomputing with the 6502 cpu


User avatar
HawaiianPi
Posts: 4218
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Enable SSH before first boot

Wed Dec 14, 2016 9:43 pm

hansotten wrote:I do that all the time, no keyboard/display required . SSH is enabled at first boot.
Not any more. As of the 2016-11-25 release SSH has been disabled by default for better security.

To enable it, create a file called ssh in the boot partition (the only partition that's normally visible to Windows and Mac computers). The ssh file does not have to contain anything, it's presence tells Raspbian you want SSH enabled and the file will be deleted after that's done.

https://www.raspberrypi.org/blog/a-secu ... ian-pixel/
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

User avatar
HawaiianPi
Posts: 4218
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Enable SSH before first boot

Wed Dec 14, 2016 11:48 pm

Oh, and they finally fixed the /boot/wpa_supplicant.conf bug in Jessie Lite. So you can put your wpa_supplicant.conf file into the /boot partition (the only partition on the card visible to Windows) and it will be moved to the correct location and your Pi will connect to your wireless network.

This convenient feature was available on the full GUI version of Raspbian since last May, but prior to the 11-25 release it didn't work on Jessie Lite. So now it's finally possible to make a fully headless boot version of Jessie-Lite on a Windows computer by placing both the wpa_supplicant.conf and ssh files into /boot after imaging the card. Note that the ssh file doesn't have to contain anything, but the wpa_supplicant.conf file needs your wireless info as follows:

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
	ssid="your-network-service-set-identifier"
	psk="your-network-WPA/WPA2-security-passphrase"
	key_mgmt=WPA-PSK
}
Edit country=, ssid= and psk= then save the file to the boot partition of the SD card.

I tested this on my Pi-Zero with only an OTG WiFi dongle and it worked.
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

mezaomar
Posts: 1
Joined: Tue Jan 17, 2017 4:20 pm

Re: Enable SSH before first boot

Tue Jan 17, 2017 4:24 pm

Its now in Documentation:
https://www.raspberrypi.org/documentati ... /README.md
ENABLE SSH

As of the November 2016 release, Raspbian has the SSH server disabled by default. You will have to enable it manually. This is done using raspi-config:

Enter sudo raspi-config in the terminal, first select Interfacing options, then navigate to ssh, press Enter and select Enable or disable ssh server.

For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.

0xFFFFAA
Posts: 1
Joined: Sun Mar 12, 2017 2:20 pm

Re: Enable SSH before first boot

Sun Mar 12, 2017 2:23 pm

For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card.
Can someone explain how does this work?
I mean what script does check for this file. Also will be good to know what copies wpa_supplicant.conf from /boot

gbetous
Posts: 2
Joined: Sun Jun 03, 2012 9:08 am

Re: Enable SSH before first boot

Mon Oct 23, 2017 5:55 am

Hi !

The answer is in /etc/systemd/system/multi-user.target.wants/sshswitch.service

On every start, it is executed only if those files exists (ConditionPathExistsGlob). If executed, it enables ssh (for next reboots), start ssh (for this reboot), then remove the /boot/ssh /boot/ssh.txt files

bsdnilux
Posts: 14
Joined: Tue Dec 26, 2017 9:05 am

Re: Enable SSH before first boot

Fri Jan 26, 2018 6:13 pm

Kagetaze wrote:
Tue Dec 22, 2015 9:16 am
Hello everyone!

Bit of an odd question to you all, perhaps. I know (as I've done it a million times before) that when I downloaded and port Raspian to the RPI on the SD card that upon first boot, I go through the raspi-config (it shows up unasked)

Let's assume for scientific reasons that I currently have no access to a keyboard to go through this menu. Is there a way to activate SSH so that I can connect to it, then go through the menu through putty?

Thanks!
Hi Kagetaze,

Have you managed to find a proper answer (non lamers) to your answer ?

I have similar inquiry.

Thank you

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

Re: Enable SSH before first boot

Fri Jan 26, 2018 6:43 pm

bsdnilux wrote:
Fri Jan 26, 2018 6:13 pm
Kagetaze wrote:
Tue Dec 22, 2015 9:16 am
Hello everyone!

Bit of an odd question to you all, perhaps. I know (as I've done it a million times before) that when I downloaded and port Raspian to the RPI on the SD card that upon first boot, I go through the raspi-config (it shows up unasked)

Let's assume for scientific reasons that I currently have no access to a keyboard to go through this menu. Is there a way to activate SSH so that I can connect to it, then go through the menu through putty?

Thanks!
Hi Kagetaze,

Have you managed to find a proper answer (non lamers) to your answer ?

I have similar inquiry.

Thank you

The Raspberry Pi Foundation documentation referred to by user @mezaomar just over 12 months ago remains available and is still accurate.

User avatar
HawaiianPi
Posts: 4218
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Enable SSH before first boot

Sat Jan 27, 2018 2:08 am

bsdnilux wrote:
Fri Jan 26, 2018 6:13 pm
Hi Kagetaze,

Have you managed to find a proper answer (non lamers) to your answer ?

I have similar inquiry.

Thank you
If you had bothered to actually read the thread you replied to you would already have your answer. :roll:
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Banjankri
Posts: 5
Joined: Mon Aug 11, 2014 12:23 am

Re: Enable SSH before first boot

Wed Feb 28, 2018 4:45 pm

Few years later, here's the non-lamers answer:

The boot partition on a Pi should be accessible from any machine with an SD card reader, on Windows, Mac, or Linux. If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory. The contents of the file don’t matter: it can contain any text you like, or even nothing at all. When the Pi boots, it looks for this file; if it finds it, it enables SSH and then deletes the file. SSH can still be turned on or off from the Raspberry Pi Configuration application or raspi-config; this is simply an additional way to turn it on if you can’t easily run either of those applications.

So just add a file "ssh" to /boot :)

User avatar
HawaiianPi
Posts: 4218
Joined: Mon Apr 08, 2013 4:53 am
Location: Aloha, Oregon USA

Re: Enable SSH before first boot

Wed Feb 28, 2018 10:12 pm

Banjankri wrote:
Wed Feb 28, 2018 4:45 pm
Few years later, here's the non-lamers answer:

So just add a file "ssh" to /boot :)
Actually, you add it to the small FAT32 "boot" partition, not /boot (which is a directory on the ext4 partition).

So image your SD card with the latest Raspbian (preferably with Etcher) then eject the card and re-insert it so that your Windows/Mac PC can see the small FAT32 partition (labelled boot). Open that partition and create a file called shh or ssh.txt (it can be empty, the contents don't matter). All of which was covered back in 2016 when I first replied to this thread.

viewtopic.php?p=1082188#p1082188
My mind is like a browser. 27 tabs are open, 9 aren't responding,
lots of pop-ups...and where is that annoying music coming from?

Return to “General discussion”