hakelm
Posts: 30
Joined: Wed Mar 20, 2013 12:23 pm

Raspian easy install. Instant networking and SSH.

Wed Mar 29, 2017 11:57 am

When installing a new Raspian I need to connect a display and a keyboard just to enable SSH and Wifi, something that at least for me is a bit cumbersome.
It would be much nicer to prepare the image already on the computer from which I copy the OS-image.
Is there any way to do this?
1) What files and what content do I have to create/change to enable SSH?
2) What files and what content do I have to create/change to enable Wifi?
Thanks in advance for any tip
H

mikerr
Posts: 2827
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Raspian easy install. Instant networking and SSH.

Wed Mar 29, 2017 12:04 pm

1) download the raspbian image (not NOOBS) from here:
https://www.raspberrypi.org/downloads/raspbian/

2) write that image to SD card using win32diskimager or etcher

3) create empty file ssh.txt on the SD card boot partition (same place as config.txt)

4) create a file called wpa_supplicant.conf on the SD card boot partition containing:

Code: Select all

network={
   ssid="your SSID"
   psk="your passphrase"
}
Done !
Last edited by mikerr on Wed Mar 29, 2017 2:43 pm, edited 1 time in total.
Android app - Raspi Card Imager - download and image SD cards - No PC required !

hakelm
Posts: 30
Joined: Wed Mar 20, 2013 12:23 pm

Re: Raspian easy install. Instant networking and SSH.

Wed Mar 29, 2017 12:21 pm

Thanks.
I understand the /etc/wpa_supplicant/wpa_supplicant.conf bit.
But I can't grasp what ssh.txt does. Where should it be placed?
H

pcmanbob
Posts: 9497
Joined: Fri May 31, 2013 9:28 pm
Location: Mansfield UK

Re: Raspian easy install. Instant networking and SSH.

Wed Mar 29, 2017 12:27 pm

hakelm wrote:Thanks.
I understand the /etc/wpa_supplicant/wpa_supplicant.conf bit.
But I can't grasp what ssh.txt does. Where should it be placed?
H
Hi.

ssh.txt just tells the OS to enable ssh, just like you were doing via the display and keyboard.
on a windows pc you will only see one partition on your sd card that's were you need to put it, you need to put your wpa_supplicant.conf file in there as well.
We want information… information… information........................no information no help
The use of crystal balls & mind reading are not supported

klricks
Posts: 7161
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Raspian easy install. Instant networking and SSH.

Wed Mar 29, 2017 12:33 pm

hakelm wrote:Thanks.
I understand the /etc/wpa_supplicant/wpa_supplicant.conf bit.
But I can't grasp what ssh.txt does. Where should it be placed?
H
If a file with the name ssh or ssh.txt is put into the /boot folder then ssh will automatically be enabled when booted in the RPi.
If successful then the ssh file will be deleted.

If a valid file wpa_supplicant.conf is put in /boot then it will automatically be moved to the /etc/wpa_supplicant/ on boot.

The above allows the user to prepare for a headless setup beforehand and then have access on first boot.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

hakelm
Posts: 30
Joined: Wed Mar 20, 2013 12:23 pm

Re: Raspian easy install. Instant networking and SSH.

Wed Mar 29, 2017 3:26 pm

Thanks again,
I am not using Windows so I couldn't understand but now I do. I will test it soon.
H

hakelm
Posts: 30
Joined: Wed Mar 20, 2013 12:23 pm

Re: Raspian easy install. Instant networking and SSH.

Wed Apr 05, 2017 6:49 am

I installed a fresh Raspian today using your instructions. Wifi and SSH instantly up.
Your prescription should really be part of the official installation instructions.
Thanks again
H

jahboater
Posts: 5797
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Raspian easy install. Instant networking and SSH.

Wed Apr 05, 2017 7:47 am

hakelm wrote:I installed a fresh Raspian today using your instructions. Wifi and SSH instantly up.
Your prescription should really be part of the official installation instructions.
Thanks again
H
Well done!

If your PC runs Linux, then you can mount the second ext4 partition and make any changes you like to that directly. The second partition contains the OS proper. You could for example set a static IP address in /etc/dhcpcd.conf (so its easy to find), change the ssh config in /etc/ssh, copy in any files to /home/pi and so on.

Windows will not always see more than one partition on a removable drive and if it did see two, it would not understand ext4 so Raspbian allows you to put the Wifi credentials in the FAT partition.

ssh is no longer enabled by default, so the "ssh" file trick is needed (in Linux just do ">ssh" to create the file).

memilanuk
Posts: 53
Joined: Fri Aug 09, 2013 2:20 pm

Re: Raspian easy install. Instant networking and SSH.

Wed Apr 05, 2017 2:20 pm

Just throwing this out there... check out Diet Pi. There are a number of other benefits in my opinion, but one very nice thing is that rather than having to muck about finding a way to mount ext4 partitions in Windows or Mac OS X and then figuring out which file(s) to modify... you just edit one file - dietpi.txt - in the root directory of the image that you write to the SD card. Put your wifi info in there, and on first boot Diet Pi's config process will a) take that info and put it where it needs to be and b) automatically has Dropbear (ssh) enabled (as it should be), so no need for a separate ssh.txt file.

Return to “Raspberry Pi OS”