rockrabbit
Posts: 9
Joined: Sat Mar 04, 2017 12:52 am

sudo touch boot/ssh does not work

Sat Mar 04, 2017 11:18 pm

Greetings,

A little annoyed... I mounted my micro SD with a fresh install of Raspbian Jessie Lite into my SD card reader and plugged it into my working Pi 3.

sudo mount /dev/sda2 /mnt

cd /mnt

cd boot

nothing in there

cd ..

sudo touch boot/ssh

cd boot

now there is a file called "ssh" in there

Edit the files to setup wifi

Unmount and place the micro SD into my Pi Zero

Scan for the IP

ssh [email protected]

Connection refused!

Any help?

User avatar
topguy
Posts: 5618
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: sudo touch boot/ssh does not work

Sat Mar 04, 2017 11:56 pm

The boot partition is sda1 isnt it ? You should find the root directory of raspbian on sda2.

rockrabbit
Posts: 9
Joined: Sat Mar 04, 2017 12:52 am

Re: sudo touch boot/ssh does not work

Sat Mar 04, 2017 11:57 pm

sda1 is the pi3

sda2 is the mount of the fresh install microSD card

User avatar
topguy
Posts: 5618
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: sudo touch boot/ssh does not work

Sun Mar 05, 2017 12:47 am

I'm pretty sure the onboard SD-card card under Raspbian is "mmcblk0", check with "mount" command.
Anyway if the Rpi3 is "sda" then the other card in the reader should have been "sdb"

/dev/sda is a disk or card
/dev/sda1 is the first partition in that disk
/dev/sda2 is the second partition on that disk.

rockrabbit
Posts: 9
Joined: Sat Mar 04, 2017 12:52 am

Re: sudo touch boot/ssh does not work

Sun Mar 05, 2017 1:17 am

I assure you, SDA2 is the new install..


I mount the microSD card into a SD card reader.. plug it into a USB port on the Pi3

ssh into my Pi3

I do a

Code: Select all

df -h
and look:

Code: Select all

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  3.4G   11G  25% /
devtmpfs        363M     0  363M   0% /dev
tmpfs           367M     0  367M   0% /dev/shm
tmpfs           367M  5.1M  362M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           367M     0  367M   0% /sys/fs/cgroup
/dev/mmcblk0p1   63M   22M   42M  35% /boot
tmpfs            74M     0   74M   0% /run/user/1000
I then do:

Code: Select all

sudo mount /dev/sda2 /mnt
I do a

Code: Select all

df -h

Code: Select all

Filesystem      Size  Used Avail Use% Mounted on
/dev/root        15G  3.4G   11G  25% /
devtmpfs        363M     0  363M   0% /dev
tmpfs           367M     0  367M   0% /dev/shm
tmpfs           367M  5.1M  362M   2% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           367M     0  367M   0% /sys/fs/cgroup
/dev/mmcblk0p1   63M   22M   42M  35% /boot
tmpfs            74M     0   74M   0% /run/user/1000
/dev/sda2        15G  792M   13G   6% /mnt
yip, my 16Gb microSD card at the bottom...

I then enter

Code: Select all

cd /mnt
I do an

Code: Select all

ls

Code: Select all

bin  boot  dev  etc  home  lib  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
I edit my wifi settings kinda like what is found here:

https://davidmaitland.me/2015/12/raspbe ... ess-setup/

Prior to the change of turning off SSH, I would unmount and plug the microSD card into my Pi Zero and wait a minute, then SSH straight into it.

Now though I can no longer connect.

I'm following the instructions as provided by Raspberry Pi Foundation:

https://www.raspberrypi.org/documentati ... /README.md
For headless setup, SSH can be enabled by placing a file named 'ssh', without any extension, onto the boot partition of the SD card. When the Pi boots, it looks for the 'ssh' file; if it is found, SSH is enabled and then the file is deleted. The content of the file doesn't matter: it could contain either text or nothing at all.
It just does not work... I'm stumped... I would love to hear a solution!

User avatar
topguy
Posts: 5618
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: sudo touch boot/ssh does not work

Sun Mar 05, 2017 1:49 am

You are right that sda is the correct card, but sda2 its still the wrong partition. Try to mount /dev/sda1 instead and find the boot files there.

Do you see what is mounted in "/boot" ?
/dev/mmcblk0p1 63M 22M 42M 35% /boot

This is the first partition (the boot partition) on the card that the RPI3 boots from. You mount /dev/sda1 you will find similar files.
This also explains why there is an empty "/boot" directory on "/dev/sda2" because it needs a place to mount the boot partition when you boot on that card.

rockrabbit
Posts: 9
Joined: Sat Mar 04, 2017 12:52 am

Re: sudo touch boot/ssh does not work

Sun Mar 05, 2017 2:03 am

if i do this:

Code: Select all

sudo mount /dev/sda1 /mnt
and then an ls, I get greeted with this:

Code: Select all

bcm2708-rpi-0-w.dtb     bcm2709-rpi-2-b.dtb  cmdline.txt    fixup.dat     kernel7.img       Network Trash Folder  start.elf
bcm2708-rpi-b.dtb       bcm2710-rpi-3-b.dtb  config.txt     fixup_db.dat  kernel.img        overlays              start_x.elf
bcm2708-rpi-b-plus.dtb  bcm2710-rpi-cm3.dtb  COPYING.linux  fixup_x.dat   LICENCE.broadcom  start_cd.elf          Temporary Items
bcm2708-rpi-cm.dtb      bootcode.bin         fixup_cd.dat   issue.txt     LICENSE.oracle    start_db.elf
If i do:

Code: Select all

sudo touch boot/ssh
I get:

Code: Select all

touch: cannot touch ‘boot/ssh’: No such file or directory

I'm sure its the SDA2 partition they are referring too where there is a Boot folder that is empty right up till I do:

Code: Select all

sudo touch boot/ssh

If I look at the boot folder on the Pi3 (where SSH is enabled) I see this:

Code: Select all

bcm2708-rpi-0-w.dtb     bcm2709-rpi-2-b.dtb  cmdline.txt    fixup.dat     kernel7.img       overlays      start_x.elf
bcm2708-rpi-b.dtb       bcm2710-rpi-3-b.dtb  config.txt     fixup_db.dat  kernel.img        start_cd.elf
bcm2708-rpi-b-plus.dtb  bcm2710-rpi-cm3.dtb  COPYING.linux  fixup_x.dat   LICENCE.broadcom  start_db.elf
bcm2708-rpi-cm.dtb      bootcode.bin         fixup_cd.dat   issue.txt     LICENSE.oracle    start.elf

back to SDA1

I do the following:

Code: Select all

sudo touch ssh
a file is created...

I unmount and plug it in my Pi Zero...

and get greeted with:

Code: Select all

ssh: connect to host 10.0.1.10 port 22: Connection refused

User avatar
topguy
Posts: 5618
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: sudo touch boot/ssh does not work

Sun Mar 05, 2017 3:00 am

And this is a card installed with a Raspbian Jessie lite image ? Or is it a NOOBS card with an Jessie Lite installation ?
Those "Network Trash Folder" and "Temporary Items" sounds very "Windows"....

rockrabbit
Posts: 9
Joined: Sat Mar 04, 2017 12:52 am

Re: sudo touch boot/ssh does not work

Sun Mar 05, 2017 3:06 am

FIXED!

I re-imaged the card

From my Mac in Terminal

cd /Volumes/boot

sudo touch ssh

Ejected, took it over to a SD card reader and plugged it into my Pi3

mounted SDA2 and did my wifi settings

unmounted the card and took it over to the Pi Zero

Loaded up FING on my iPhone and waited to see the IP that is MAC Address assigned.. that took a while...

Then I did ssh [email protected]

and Bingo!

https://www.raspberrypi.org/blog/a-secu ... ian-pixel/

This thread was helpful... as you were dear Sir!

steelnwool
Posts: 3
Joined: Sat Nov 25, 2017 2:49 am

Re: sudo touch boot/ssh does not work

Sat Nov 25, 2017 2:51 am

Is this `touch /Volumes/boot/ssh` trick documented anywhere official?

User avatar
topguy
Posts: 5618
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: sudo touch boot/ssh does not work

Sat Nov 25, 2017 5:26 pm

Background here: https://www.raspberrypi.org/blog/a-secu ... ian-pixel/ ( even if Pixel is not official name anymore )

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

Re: sudo touch boot/ssh does not work

Sat Nov 25, 2017 5:34 pm

It is also written up in the Raspberry Pi Foundation documentation in support of Remote Access, in Section 3 of this link: https://www.raspberrypi.org/documentati ... /README.md

After 12 months I don't think it needs to be given the status of a 'trick.'

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: sudo touch boot/ssh does not work

Sat Nov 25, 2017 6:03 pm

steelnwool wrote:
Sat Nov 25, 2017 2:51 am
Is this `touch /Volumes/boot/ssh` trick documented anywhere official?
The issue here is how much - to what degree and depth - should we be supporting non-Pi OSes - that is, OSes not running on Pi hardware. Here, the /Volumes thing is a Mac thing - really has nothing to do with the Pi at all.

The "touch /boot/ssh" thing - that which is usually quoted in the various support documents and by forum participants - is specific to one specific scenario - described below:

1) You have monitor and keyboard connected to the Pi.
2) You boot up the Pi, login on the HDMI screen, and now want to enable SSH.
3) Using the connected keyboard and screen, you can now open up a terminal window and do "touch /boot/ssh". When you reboot, the magic happens. SSH will be enabled.

However, what emerges is that:
1) In the scenario described above, you don't really need to do it that way anyway, since you can (and should) enable ssh via the Raspiconfig program (either via the command line or via the GUI version).
2) So, the only time this is actually relevant is when you are trying to set it up entirely headless - that is, with no access to a keyboard/screen at all. Personally, I think this is a pretty ill-advised thing to do - people think that because they want to run headless, that they need to do the setup that way as well. Yes, I understand that in certain extreme cases, it is necessary.

So, when are in case 2) above, where you have no screen/keyboard at all, then you need to use whatever commands are necessary in whatever other OS you have access to, to create the 'ssh' file in the root of the boot partition of the SD card. On Mac, that would be somewhere under /Volumes. On a Windows PC, it would be something like "F:\", And note that recent versions of the Mac OS have a "touch" command, but most Windows PC don't, so you'll need to know which commands to use on that platform that have the same effect as the Unix "touch" command.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

User avatar
rpdom
Posts: 14742
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: sudo touch boot/ssh does not work

Sat Nov 25, 2017 7:17 pm

n67 wrote:
Sat Nov 25, 2017 6:03 pm
2) So, the only time this is actually relevant is when you are trying to set it up entirely headless - that is, with no access to a keyboard/screen at all. Personally, I think this is a pretty ill-advised thing to do - people think that because they want to run headless, that they need to do the setup that way as well. Yes, I understand that in certain extreme cases, it is necessary.
How about just preferable?
Almost all of my Raspberries have been set up headless with no need for screen or keyboard. I don't need the hassle of digging those out and connecting them up. Instead I use a little bash script I wrote that prompts me for the image to write to the card and sets up everything I want for the initial build to make a usable system I can ssh into and customise the config.

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

Re: sudo touch boot/ssh does not work

Sun Nov 26, 2017 4:38 am

rockrabbit wrote:
Sun Mar 05, 2017 2:03 am
if i do this:

Code: Select all

sudo mount /dev/sda1 /mnt
and then an ls, I get greeted with this:

Code: Select all

bcm2708-rpi-0-w.dtb     bcm2709-rpi-2-b.dtb  cmdline.txt    fixup.dat     kernel7.img       Network Trash Folder  start.elf
bcm2708-rpi-b.dtb       bcm2710-rpi-3-b.dtb  config.txt     fixup_db.dat  kernel.img        overlays              start_x.elf
bcm2708-rpi-b-plus.dtb  bcm2710-rpi-cm3.dtb  COPYING.linux  fixup_x.dat   LICENCE.broadcom  start_cd.elf          Temporary Items
bcm2708-rpi-cm.dtb      bootcode.bin         fixup_cd.dat   issue.txt     LICENSE.oracle    start_db.elf
That is correct, so far...
rockrabbit wrote:
Sun Mar 05, 2017 2:03 am
If i do:

Code: Select all

sudo touch boot/ssh
I get:

Code: Select all

touch: cannot touch ‘boot/ssh’: No such file or directory
And this is where you go wrong. There is no /boot directory on /dev/sda1 because /dev/sda1 *IS* the /boot directory. When the SD card is mounted as the primary OS drive, the first partition gets mounted to /boot, and the second partition is / (root). So the correct way to mount the entire card in /mnt would be to mount /dev/sda2 to /mnt, then /dev/sda1 to /mnt/boot.

However, for the purpose of creating the ssh file in the boot directory, simply mounting /dev/sda1 to /mnt and sudo touch /mnt/ssh will work.
rockrabbit wrote:
Sun Mar 05, 2017 2:03 am
I'm sure its the SDA2 partition they are referring too where there is a Boot folder that is empty right up till I do:

Code: Select all

sudo touch boot/ssh
It's empty because another partition gets mounted there at boot time, and anything you put in /dev/sda2/boot will get replaced by the contents of the actual boot partition when it gets mounted (the actual boot partition = /dev/sda1 when you are editing the card in your card reader).
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
ksharindam
Posts: 119
Joined: Sat Jan 09, 2016 4:16 pm

Re: sudo touch boot/ssh does not work

Sun Nov 26, 2017 5:32 am

Believe it or not...
  • /dev/sda1 is the boot partition. boot partition doesnot contain any folder named boot
  • /dev/sda2 is the root partition, that contains a boot folder which is the mountpoint of boot partition. so this boot folder is empty.
  • The documentation you are saying is applicable for the sdcard you are running (inserted in slot of raspberry pi), not for the card you inserted in a card reader.
So you have to do...

Code: Select all

sudo mount /dev/sda1 /mnt
sudo touch /mnt/ssh
Done.

This will create an empty file ssh in the boot partition.
My Qt projects at ... https://github.com/ksharindam

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

Re: sudo touch boot/ssh does not work

Sun Nov 26, 2017 7:41 am

To endorse and confirm what the preceding 2 posts say:

The Raspberry Pi Foundation documentation I referred to says -
SSH can be enabled by placing a file named ssh, without any extension, onto the boot partition of the SD card from another computer...

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 looks correct to me.

steelnwool
Posts: 3
Joined: Sat Nov 25, 2017 2:49 am

Re: sudo touch boot/ssh does not work

Mon Nov 27, 2017 3:32 pm

I agree the note on https://www.raspberrypi.org/documentati ... ccess/ssh/ re :
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.
Is totally adequate. I just wasn't sure where it was.

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: sudo touch boot/ssh does not work

Mon Nov 27, 2017 3:39 pm

steelnwool wrote:
Mon Nov 27, 2017 3:32 pm
I agree the note on https://www.raspberrypi.org/documentati ... ccess/ssh/ re :
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.
Is totally adequate. I just wasn't sure where it was.
But that doesn't document the /Volumes/boot part at all.

It doesn't document how to find that particular location on your Mac. I assumed that was the part that you were asking about.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

User avatar
DougieLawson
Posts: 35542
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: sudo touch boot/ssh does not work

Mon Nov 27, 2017 5:54 pm

n67 wrote:
Mon Nov 27, 2017 3:39 pm

But that doesn't document the /Volumes/boot part at all.

It doesn't document how to find that particular location on your Mac. I assumed that was the part that you were asking about.
Could that be, because it's trying to be creating system agnostic. The device layout on Windows vs Linux vs a BSD clone (aka OSX 10.13) isn't something that needs to be specifically documented in Raspberry Pi documentation. It's up to you to know what convention your machine uses.
Note: Having anything remotely humorous in your signature is completely banned on this forum. Wear a tinfoil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

steelnwool
Posts: 3
Joined: Sat Nov 25, 2017 2:49 am

Re: sudo touch boot/ssh does not work

Wed Nov 29, 2017 12:55 pm

Sorry, my very specific example led us down an awkward path. I didn't mean is "touch /Volumee/boot/ssh" specifically documented.

What I actually meant was "is it documented that you can just place a file in /boot, via any method at all and it will enable ssh?"

and the resulting answer was "yes", with a link. I'm happy with that answer.

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: sudo touch boot/ssh does not work

Wed Nov 29, 2017 2:37 pm

I didn't mean is "touch /Volumee/boot/ssh" specifically documented.
I assumed you did - and I think it was perfectly reasonable for me to assume that.

But let me re-iterate once more that the idea of:
you can just place a file in /boot
Is just as wrong as the idea that you can put something in /Volumes/whatever, because it, like the Mac version, is system- and context- specific. For all practical purposes, it only works on a booted Raspbian (and, possibly, other supported Pi OSes - which are all, at the level we are talking here, equivalent to Raspbian) system.

For all practical purposes, the best advice for how to put the 'ssh' file in the right place is this:
Figure out which drive your Windows system has mounted your SD card at. Let's assume it is "F:". Then open up a Command Prompt window and do:

Code: Select all

C> echo.>F:\ssh
C>exit
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

User avatar
DougieLawson
Posts: 35542
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: sudo touch boot/ssh does not work

Thu Nov 30, 2017 7:27 am

steelnwool wrote:
Wed Nov 29, 2017 12:55 pm
What I actually meant was "is it documented that you can just place a file in /boot, via any method at all and it will enable ssh?"

and the resulting answer was "yes", with a link. I'm happy with that answer.
https://www.raspberrypi.org/blog/a-secu ... ian-pixel/
Note: Having anything remotely humorous in your signature is completely banned on this forum. Wear a tinfoil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

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

Re: sudo touch boot/ssh does not work

Fri Dec 01, 2017 9:28 pm

steelnwool wrote:
Wed Nov 29, 2017 12:55 pm
Sorry, my very specific example led us down an awkward path. I didn't mean is "touch /Volumee/boot/ssh" specifically documented.

What I actually meant was "is it documented that you can just place a file in /boot, via any method at all and it will enable ssh?"

and the resulting answer was "yes", with a link. I'm happy with that answer.
Nope, you've still got it wrong.

What you do is place the ssh or ssh.txt file into the first FAT32 partition, which is labelled "boot" and gets mounted to /boot by Raspbian. The difference being that it can be done on any system, Windows, Mac, Linux, without regard to whether or not the system can read the second partition's ext4 filesystem, because almost everything can read that tiny FAT32 first partition.

You really need to get over the whole /boot obsession you seem to have going on there. You DO NOT put the file in /boot, you put it on the first FAT32 partition of a Raspbian imaged SD card. You do absolutely nothing to the 2nd partition and the /boot folder that is in the 2nd partition.

Got it?
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?

n67
Posts: 938
Joined: Mon Oct 30, 2017 4:55 pm

Re: sudo touch boot/ssh does not work

Sat Dec 02, 2017 9:35 am

What I actually meant was "is it documented that you can just place a file in /boot, via any method at all and it will enable ssh?"
Nope, you've still got it wrong.
The underlying point here is that OP is simply asserting the very basic - and by now understood by everybody, except maybe him - fact that, yes, you now need to jump through hoops to get SSH working (whereas, before, no such hoops needed to be jumped).

That realization (by OP) falls into the general category of "Trite but True".

However, as I've mentioned several times now, the specifics of putting the file there, are OS- and context- specific.
Under Windows (the most common case), you need, of course, to figure out what drive letter the SD card is mounted at, and then do the appropriate Command Prompt commands to create the file.
"L'enfer, c'est les autres"

G fytc hsqr rum umpbq rm qyw rm rfc kmbq md rfgq dmpsk:

Epmu Sn!

J lnacjrw njbruh-carppnanm vxm rb mnuncrwp vh yxbcb!

Return to “Raspbian”