0

In the past, adding an empty file /boot/ssh from Windows (because boot partition is a FAT32 partition) was enough to setup a fresh RaspiOS install for a headless RPi without screen.

Now it seems that even if /boot/ssh is created, it is no longer possible to ssh with Putty on [email protected] with password raspberry.

Question: how to enable SSH with password on a fresh headless RPi install, with Windows?

How to activate login=pi password=raspberry without having a screen monitor?

PS: I see the reason why they disabled the legacy way (security), but the current design is poor. We should be able to setup a headless RPi without using a monitor.

8
  • 1
    We should be able to setup a headless RPi without using a monitor. still possible. Use pi-imager to write and set up PiOS. Refer to e.g. the official docs
    – Dirk
    Commented Jun 17, 2023 at 11:30
  • Try reading the documentation for Raspberry Pi Imager but is it REALLY that hard to use a screen & keyboard for initial setup? "the current design" is how every other Linux OS is setup.
    – Milliways
    Commented Jun 17, 2023 at 11:58
  • Why are you trying a fresh install? Just update your current install.
    – Milliways
    Commented Jun 17, 2023 at 11:59
  • 1
    is it REALLY that hard to use a screen & keyboard for initial setup: Yes as I'm often working during trips, and I only have backpack + laptop + a few RPi. Also, it contradicts the whole spirit of a headless RPi, if you have to use a screen to set it up...
    – Basj
    Commented Jun 17, 2023 at 12:15
  • 1
    With pi-imager you just install the image and use the advanced options to set up user, networking (wifi, etc), ssh, etc. No need for any manual actions afterward. As I said: read the official docs.
    – Dirk
    Commented Jun 17, 2023 at 14:49

3 Answers 3

3

If you really want to do this without normal setup follow the instructions:-

Configuring a User

which is part of the documented process for Setting up a Headless Raspberry Pi:

IMPORTANT
If you are installing Raspberry Pi OS, and intend to run it headless, you will need to create a new user account. Since you will not be able to create the user account using the first-boot wizard as it requires both a monitor and a keyboard, you MUST add a userconf.txt file to the boot folder to create a user on first boot or configure the OS with a user account using the Advanced Menu in the Raspberry Pi Imager.

The imager has options to to this at imaging stage.

This was also explained in the blog Raspberry Pi Bullseye Update of 7th Apr 2022 which announced the security change.

If you search the internet you will even find ready made userconf.txt files to set pi:raspberry

1
  • Thanks a lot @Milliways! This userconf.txt file seems to be the solution for my use case! Thanks
    – Basj
    Commented Jun 18, 2023 at 10:44
3

with Windows? ... it contradicts the whole spirit of a headless RPi, if you have to use a screen to set it up...

Then in the spirit of such install a linux VM on your windows box so you can access the primary ext4 partition with the OS root filesystem on it, and it is as simple as:

export mountpoint=/mnt/sd # Or wherever it's mounted.
ln -s /lib/systemd/system/ssh.service ${mountpoint}/etc/systemd/system/default.target.wants/

It may be worth noting that the first path given to ln -s is recorded in the second path, so at this it will point to the ssh.service in the running system (if that path exists, which it will for most debian derived distros at least), but when the card is put back in the Pi will point to the one on the card. In any case, make sure the link exists in ${mountpoint}/etc/systemd/....

Then:

cd ${mountpoint}/etc/ssh/
rm -f ssh_host_*key*
ssh-keygen -A 
cd ~

Alternately, you can enable sshswitch instead of ssh, then add a /boot/ssh and that will work to do much the same thing.

1
  • 1
    Thanks a lot @goldilocks. Yes this will probably work. It is just sad that all these extra steps are needed to setup a simple headless RPi. It was too good before :) when just creating /boot/ssh empty file was enough :)
    – Basj
    Commented Jun 17, 2023 at 14:44
0

As mentioned in comments, Raspberry Pi Imager is now the way to go, it is available even in Windows, and we can customize the install with these steps, before writing the image to the microSD card:

enter image description here

enter image description here

Then we can directly SSH connect via WiFi, also there is no need to find the IP address, the hostname "raspberrypi" is enough to locate the Pi!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.