Enable headless ssh

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
Juca Navaz Reque
Posts: 1
Joined: Tue Jan 01, 2019 2:33 am

Enable headless ssh

Post by Juca Navaz Reque »

Hi, I just bought a new Raspberry Pi 3 model B+, and I'm really new to all this, so sorry if the question is too obvious.

The problem is that I don't have an USB keyboard (I'll get one later, but I don't want to wait to start doing things), so I must enable a headless ssh connection, in order to be able to work with my Raspberry on my laptop using PuTTY and an Ethernet cable (if I'm not wrong). The problem is that I don't know how to do this. I've edited the dietpi.txt file in the SD, and changed the following lines:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Enter your Static Network details below, if applicable.
AUTO_SETUP_NET_USESTATIC=1
AUTO_SETUP_NET_STATIC_IP=192.168.0.100
AUTO_SETUP_NET_STATIC_MASK=255.255.255.0
AUTO_SETUP_NET_STATIC_GATEWAY=192.168.0.1
AUTO_SETUP_NET_STATIC_DNS=8.8.8.8

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

# Fully automate the installation
# 1=Automated installation with no user inputs.
# It is HIGHLY recommended to also set CONFIG_BOOT_WAIT_FOR_NETWORK=2, to force infinite wait for network connection during boot, preventing no connection errors due to timeout.
AUTO_SETUP_AUTOMATED=1

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

#Delay boot until network is established: 0=disabled | 1=10 second wait max (default) | 2=infinite wait
CONFIG_BOOT_WAIT_FOR_NETWORK=2

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

By doing this, I supposed that I would be able to set a static IP in the board, so when I plug it via Ethernet to my laptop, I'd be able to access it, but I can't. I've tried to connect to 192.168.0.100 several times (even after restarting Raspberry and my computer) and it doesn't work. Also, if I execute an IP scanner, it doesn't seem to recognize the board. I've ensured Raspberry is plugged and working (I tested it with a screen and waited until text stopped appearing), so I don't know how to proceed, as most tutorials I find on internet are based on raspbian.

As I say, I'm new on this, so if you could also give an explanation on what I'm doing wrong and why what I tried didn't work, I would appreciate it.
Thank you ;­)

User avatar
WarHawk
Posts: 580
Joined: Thu Jul 20, 2017 7:55 am

Re: Enable headless ssh

Post by WarHawk »

You have to setup the wifi if you are not using the ethernet...otherwise it won't bring up the wifi thru SSID and the passcode

Change to CONFIG_BOOT_WAIT_FOR_NETWORK=1 (otherwise it could hang indefinitely)

It will take some time to start on initial setup, it has to resize the card then reboot a few times...so give it a few minutes on automated setup to complete.

Plus you can't connect directly to your laptop...it needs to be plugged into a switch so it can get out to the internet to do all it's setup stuff in the scripting.

ethernet to ethernet needs a crossover cable...or plug both into a switch, set your laptop ip to any other ip in your home network then ssh into 192.168.0.100...it has to be able to communicate in the subnet or it won't work
192.168.0.0/24

mrmichaelhallett
Posts: 1
Joined: Tue Apr 04, 2017 7:00 pm

Re: Enable headless ssh

Post by mrmichaelhallett »

Huh? the OP said he was using ethernet.
Most PCs and even the RPi will sense a crossover or not and adjust
You dont need a switch between 2 ethernet devices (unless they are really really old devices)

the problem is that you did not set a fixed IP on your laptop ethernet adapter
If the laptop ethernet is not connected to your router it would get a non connected default IP like (169.248.x.x) instead of an IP from the router

try something like 192.168.0.99 (has to be same subnet as the IP address of the pi)
try to ping the ip of the pi from the PC
create a file named ssh with no extension in the root of the sdcard (it can be empty)


you can do it.
be careful whom you take advice from.

User avatar
MichaIng
Site Admin
Posts: 2095
Joined: Sat Nov 18, 2017 5:21 pm

Re: Enable headless ssh

Post by MichaIng »

mrmichaelhallett wrote:
Wed Mar 25, 2020 3:58 pm
create a file named ssh with no extension in the root of the sdcard (it can be empty)
That is btw not required and does not even work on DietPi. It is a Raspbian-only feature to enable OpenSSH on first boot, but on DietPi Dropbear SSH server is installed and enabled by default. So simply boot the RPi, wait for a while until activity LED has settled, then try to ping or connect via SSH directly. Indeed for a headless setup it is best to configure a static IP via dietpi.txt before first boot, that matches the local network subnet, so you don't need to check the router which IP it assigned to the RPi via DHCP.

AUTO_SETUP_AUTOMATED=1 btw is also not required for this. It allows to you installed software titles automatically, but you can skip it, and then on first login via SSH the first run update and dietpi-software will run and prompt to allow you selecting software titles for install.

Post Reply