rtek1000
Posts: 20
Joined: Wed Mar 12, 2014 9:21 pm

[Ok] Enable SSH to Raspbian Jessie (Lite) without a monitor

Mon Mar 28, 2016 5:33 pm

Use a computer with linux and edit the /etc/rc.local file on RPi SD card:
(tested with Xubuntu 15.10 LiveCD not need install)

a. Create a empty file called etc/SSHFLAG (just open and save)
(Xubuntu: sudo mousepad /etc/SSHFLAG)

b. Insert the following code into etc/rc.local just above the exit 0 line.
(Xubuntu: sudo mousepad /etc/rc.local)

Code: Select all

if [ -e /etc/SSHFLAG ]; then
  /usr/sbin/update-rc.d -f ssh defaults
  /bin/rm /etc/SSHFLAG
  /sbin/shutdown -r now
fi
c. Save file and put SD card on RPi

d. After boot, wait RPi make one auto restart (maybe two minutes) after this can you ping to IP of RPi, if is ok, power off RPi and edit again file /etc/rc.local with computer

Now insert the following code into etc/rc.local just above the exit 0 line.

Code: Select all

sudo /etc/init.d/ssh start
e. Save file and put SD card on RPi

d. After boot, ping to IP of RPi, if is ok, try login with ssh client (putty or other)

It is all.

Sources:
http://raspberrypi.stackexchange.com/qu ... spi-config
http://www.raspberrypi-spy.co.uk/2012/0 ... pberry-pi/

DirkS
Posts: 7264
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Mon Mar 28, 2016 11:20 pm

rtek1000 wrote:It is all.
It's too much.
On Raspbian Jessie (full and lite) the SSH daemon is enabled by default...

drask
Posts: 2
Joined: Sun Nov 27, 2016 7:21 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Mon Nov 28, 2016 5:01 am

Actually, I am using 2016-05-27-raspbian-jessie-lite.img (I run apt-get update/upgrade right after I install it) and every time I have installed with it, I have had to enable ssh. I don't know if every lite image is like this, but this one definitely seems to be. It's pretty annoying since I always run these headless and log in. These instructions are a great help. When I'm setting up a new pi now, I extract the filesystem onto the SD card, then cd to the etc directory on the sd card and set up my wireless using:

Code: Select all

sudo wpa_passphrase "<my wireless network>" >> wpa_supplicant/wpa_supplicant.conf
so it's easy to do this at the same time.

I changed the script so you don't have to modify the files the second time:

Code: Select all

if [ -e /etc/SSHFLAG ]; then
  /usr/sbin/update-rc.d -f ssh defaults
  /bin/rm /etc/SSHFLAG
  /sbin/shutdown -r now
else
  /etc/init.d/ssh start
fi
It probably would be better to just go ahead and use systemd rather than continue to use the sysV commands:

Code: Select all

if [ -e /etc/SSHFLAG ]; then
  /bin/systemctl enable sshd
  /bin/rm /etc/SSHFLAG
  /sbin/shutdown -r now
fi

pirich
Posts: 1
Joined: Fri Dec 16, 2016 11:09 am

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Fri Dec 16, 2016 11:11 am

Thank you! - This last snippet works like a charm except that 'sshd' should be 'ssh'.

nsotnikov
Posts: 1
Joined: Wed Dec 28, 2016 11:33 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Wed Dec 28, 2016 11:37 pm

Now it's very simple.

If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory.

Thats all. And don't forget to change the password.

giuse320
Posts: 1
Joined: Mon Jan 09, 2017 7:17 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Mon Jan 09, 2017 7:19 pm

by nsotnikov » Wed Dec 28, 2016 11:37 pm
Now it's very simple.

If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory.

Thats all. And don't forget to change the password.

This works for me , thanks nsotnikov!

drask
Posts: 2
Joined: Sun Nov 27, 2016 7:21 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Sun Jan 15, 2017 4:49 am

pirich wrote:Thank you! - This last snippet works like a charm except that 'sshd' should be 'ssh'.
Oops, sorry. I knew I should have tried that before I posted it. That ssh/d thing gets me every time.

Also, the wpa_passphrase line should be

Code: Select all

sudo su -c 'wpa_passphrase "<my network name>" >> wpa_supplicant/wpa_supplicant.conf'
otherwise you will most likely get a "permission denied" error since the sudo only affects the wpa_passphrase command and not the redirect.

Just tried this with 2017-01-11-raspbian-jessie.img (the latest Pixel desktop version) and still found that ssh is not enabled by default.

Pulled the plug (the machine is connected to a small monitor but not to a keyboard or mouse), put the SD card back in my main computer, cd'd to the boot directory on the sd card and did a

Code: Select all

sudo touch ./ssh
and the next time ssh was enabled, as evidenced by helpful warnings that running with the default password and ssh enabled is probably not the smartest thing to do. Thanks for the tip, nsotnikov, it works well.

estarter
Posts: 1
Joined: Mon Mar 06, 2017 9:30 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Mon Mar 06, 2017 9:33 pm

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.
From https://www.raspberrypi.org/documentati ... /README.md

Add ssh file to the boot volume, simple as this.

rtek1000
Posts: 20
Joined: Wed Mar 12, 2014 9:21 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Fri Mar 10, 2017 2:34 pm

In the past, SSH was enabled by default, so people using their Pi headless could easily update their SD card to a new image. Switching SSH on or off has always required the use of raspi-config or the Raspberry Pi Configuration application, but to access those, you need a screen and keyboard connected to the Pi itself, which is not the case in headless applications. So we’ve provided a simple mechanism for enabling SSH before an image is booted.

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.
The risk with an open SSH port is that someone can access it and log in; to do this, they need a user account and a password. Out of the box, all Raspbian installs have the default user account ‘pi’ with the password ‘raspberry’. If you’re enabling SSH, you should really change the password for the ‘pi’ user to prevent a hacker using the defaults.
Source: https://www.raspberrypi.org/blog/a-secu ... ian-pixel/

arberry
Posts: 1
Joined: Wed May 17, 2017 4:52 am

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Wed May 17, 2017 5:00 am

nsotnikov wrote:If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory.
And it's very simple to do this wrong also. If you, like me, want to put this file on the memory card before booting up, then take care to mount the *small* partition which actually contains the boot *partition*, and don't mount the *large* partition, which merely contains the boot *directory* on which the small boot partition will be mounted during booting.
If you do this wrong and put the file 'ssh' in the boot directory of the large partition, then it will be temporarily overwritten by the boot partition, rendering the whole exercise without effect, i.e.: you stil won't be able to access your raspberry through ssh.

bullen
Posts: 194
Joined: Sun Apr 28, 2013 2:52 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Wed May 31, 2017 2:36 pm

Hoily &%$# this is so bad... where should one place the shh file? This is insane... the only purpose of RPI is ssh...
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

Martin Frezman
Posts: 880
Joined: Mon Oct 31, 2016 10:05 am

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Wed May 31, 2017 2:47 pm

bullen wrote:Hoily &%$# this is so bad... where should one place the shh file? This is insane... the only purpose of RPI is ssh...
Heh heh - I feel your pain.

The funny thing is that the 'ssh file in the /boot partition' thing is a typical compromise solution that pleases no one. Nobody really likes it, but we have all learned to live with it.
If this post appears in the wrong forums category, my apologies.

bullen
Posts: 194
Joined: Sun Apr 28, 2013 2:52 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Wed May 31, 2017 2:50 pm

I can't get it to work with the latest "lite" raspbian... has anyone else had the same problem?

boot partition or /boot/ folder?!

Ok, got it to work by writing the ssh file in the boot partition NOT THE /boot/ folder in the Linux partition! Phew...
https://github.com/tinspin/rupy - A tiny Java async HTTP application server.

popenoe
Posts: 1
Joined: Mon Aug 12, 2013 9:07 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Tue Jun 27, 2017 12:21 pm

Thanks! Here's to verify this works with the latest Raspbian (as of 6/21/17). When I get stuck, I always appreciate when others add extra info on these forums, so here's what I did just now:

On my laptop, running Linux Mint, I put '2017-06-21-raspbian-jessie-lite.img' on a microsd card. After mounting the 'boot' partition in my file manager, I right-clicked and selected 'Create New Document --> Empty Document' and changed the name to SSH. At the command line, typing 'nano ssh' while in the boot partition of the SD card and then saving the blank document would totally work, too. When I put it in my Pi 3 (connected to my router by ethernet cable) I immediately found it with hostname 'raspberrypi' (port 22) on the network using PuTTY and logged in as 'pi' with password 'raspberry'. Woohoo!

jahboater
Posts: 1559
Joined: Wed Feb 04, 2015 6:38 pm

Re: [Ok] Enable SSH to Raspbian Jessie (Lite) without a moni

Tue Jun 27, 2017 2:55 pm

popenoe wrote:On my laptop, running Linux Mint, I put '2017-06-21-raspbian-jessie-lite.img' on a microsd card. After mounting the 'boot' partition in my file manager, I right-clicked and selected 'Create New Document --> Empty Document' and changed the name to SSH. At the command line, typing 'nano ssh' while in the boot partition of the SD card and then saving the blank document would totally work, too.
Even easier, just type:

>ssh

in the FAT boot folder /media/xxxx/boot on your Linux Mint PC.

Return to “Troubleshooting”

Who is online

Users browsing this forum: No registered users and 28 guests