I really hate it to set up something so trivial like Raspbian Lite and then cannot SSH into the Raspberry. I googled for a solution but its so easy you would't have guessed.

If you're just looking for how to enable ssh on raspberry pi by default or how to enable ssh on boot its easy:

  1. After you followed all the steps to get the image on an SD-Card open the boot partition in your Finder/Explorer whatever.
  2. Create an empty file named: ssh  thats it.
  3. Go on and keep coding.
typical boot parition contents

How to Install Raspbian Lite on an Headless Raspberry Pi

  1. Go to: https://www.raspberrypi.org/downloads/ get the Raspberry Pi Imager for your OS
  2. Follow the instructions from the Imager Software (alternatively look here how to format the SD Card on MAC OS X: https://turais.de/how-to-format/) and copy image with cp or dd to SD-Card
  3. Open boot Partition - put an empty file with the name: ssh in the folder. It don't need to be empty - its only important the file is there.
  4. On unix you can do this with: touch ssh

If you want to use wifi put a file named: wpa_supplicant.conf in the boot folder.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=<Insert 2 letter ISO 3166-1 country code here>

network={
 ssid="<Name of your wireless LAN>"
 psk="<Password for your wireless LAN>"
}

For example:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
 ssid="WIFI"
 psk="passw0rd"
}

Country coded can be found here: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes

Its the Alpha-2-code.

5. After you're done get the SD Card in your raspberry and then we need so ssh into it.

Get the IP-Address‌

Go to your router and look for an device named raspberrypi

This is the easiest way because I guess you'll have DHCP enabled, so your router will assign an IP-Address to your raspberrypi.

Other way: nmap -sn 192.168.1.0/24 if you don't have nmap install it.

Using nmap to find the IP-Address from your raspberry it can take a while

SSH into it

for Windows download Putty. (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)

For every other OS just open an Terminal.

type: ssh pi@raspberrypi

or: ssh pi@THE_IP_YOU_LOOKED_UP like: ssh pi@192.168.178.29

The authenticity of host '192.168.178.29 (192.168.178.29)' can't be established. ECDSA key fingerprint is SHA256:9WvsumzLDV7VK28m0ErjQBctXIW7CIVZqFz835nPFhg. Are you sure you want to continue connecting (yes/no)?

Yes, we're sure. This pops up because you haven't connected to your raspberry pi before.‌

Default Username: pi Password: raspberry

Raspberry's default SSH Username and Password:

USERNAME = pi   
PASSWORD = raspberry 

Lets change Password

type passwd into the command line.

Optionally install SSH Key

Install the SSH key like so:

  • ssh-copy-id -i ~/.ssh/mykey pi@raspberrypi

Then you can login without entering the password:

Change the default password to something secure. When you type nothing will be shown - no *

Optionally disable login with root and password based login

If you have successfully logged in into your machine using your ssh-key, you can disable login with password based auths.

Type: sudo vim /etc/ssh/sshd_config or sudo nano /etc/ssh/sshd_config

PasswordAuthentication no

If you found this in anyway helpful, share it and send it to your friends. Leave a comment below or something :)

If you're planning to buy an Raspberry: Click (Amazon Ref Link)