0

I was not able to enable ssh by putting the file into the boot folder, and yes it was created without extension from a Windows 7 machine and gets deleted after boot.

This is what should have happened:

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.

(Source)

I don't want to go for Keyboard & Monitor as I can get the IP assigned to Respberry Pi 3 when I connect with ethernet and can also ping with 0% lost.

After looking for an answer I got to know that the ssh is not enabled and that's the reason putty returns Connection refused on every attempt.

Now I see there is cmdline.txt in the boot folder is it something that runs on every boot? Can I use to enable ssh? If yes, how to do it?

Here are all the details, let me know if something else is required.

  • My System: Windows 7 Update 1
  • Raspberry model: Raspberry Pi 3 B
  • Raspberry OS: Raspbian Stretch Lite
  • Monitor: No
  • Keyboard: No
  • Ping Request: responded with no packet loss
  • Connection Type: Ethernet
  • SSH: not enabled (How to?)

EDIT: Now i am able to mount the 'rootfs' to my windows 7 machine with Paragon ExtFS for Windows, but don't know how to enable ssh yet, any help is appreciated

Moved from https://superuser.com/questions/1279354/how-to-get-ssh-access-to-headless-raspbian-stretch-lite-official-way-seems-not/1279491#1279491 to here

2
  • 1
    You can have a look at this... it's written from a Mac user's perspective, but will work just as well in Windows
    – Seamus
    Commented Jun 11, 2019 at 14:36
  • I never had any problems with the ssh file. One caveat for me was local DNS. I needed to connect via IP, not by name, because the name was not present at the DNS server. See my question about this: raspberrypi.stackexchange.com/questions/100194/…
    – Marcel
    Commented Jul 12, 2019 at 6:49

1 Answer 1

2

Finally i was able to find an alternate way to enable ssh. I will try to summarize it here. I tried PiBakery also but it was too heavy with nodejs and keeps on crashing in every attempt.


The problem: Ext4 format is not readable form windows

So once you burn Raspbian through any img burning tool it creates two partition Boot & rootfs. The boot partition is formatted in FAT and will be only visible to windows whereas the rootfs was with Ext4 and will not be visible at all (you can confirm it by viewing it in MiniTool partition Partition Wizard)


Mission: Editing the configuration from windows to force enable ssh

My mission was to force enable ssh as it was not working with the official instructions (putting ssh file in the boot partition). So I downloaded the Paragon ExtFS for Windows which enables Windows 7 to browse/edit files in Ext4partition by mounting it as new drive.

Before that i also tried Ext2Fsd-0.69 but it was not compatible with Windows 7 and the other ext2explore-2.2.71 is only capable to view files not to edit them. Nothing worked for me


The hack: Edit /etc/rc.local file from windows 7

After googling for almost the whole day i got to know two thing

  1. Commands can be executed by editing the file /etc/rc.local in the rootfs partition
  2. Command to start ssh is /etc/init.d/ssh start

So i edited the rc.local file by placing the /etc/init.d/ssh start just before the exit 0 so that it executes on every boot, as follows

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

/etc/init.d/ssh start
exit 0

And it worked!! I know it's not a neat way but it can be helpful for someone in need. I must thank @KamilMaciorowski for his kind help & edits.

raspbian with ssh

Please comment below if you see any issue that may arise because of it.

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.