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:
- After you followed all the steps to get the image on an SD-Card open the
bootpartition in your Finder/Explorer whatever.
- Create an empty file named:
- Go on and keep coding.
How to Install Raspbian Lite on an Headless Raspberry Pi
- Go to: https://www.raspberrypi.org/downloads/ get the Raspberry Pi Imager for your OS
- 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
bootPartition - put an empty file with the name:
sshin the folder. It don't need to be empty - its only important the file is there.
- On unix you can do this with:
If you want to use wifi put a file named:
wpa_supplicant.conf in the boot folder.
country=<Insert 2 letter ISO 3166-1 country code here>
ssid="<Name of your wireless LAN>"
psk="<Password for your wireless LAN>"
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
This is the easiest way because I guess you'll have DHCP enabled, so your router will assign an IP-Address to your raspberrypi.
nmap -sn 192.168.1.0/24 if you don't have
nmap install it.
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.
ssh pi@THE_IP_YOU_LOOKED_UP like:
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.
Raspberry's default SSH Username and Password:
USERNAME = pi
PASSWORD = raspberry
Lets change Password
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:
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.
sudo vim /etc/ssh/sshd_config or
sudo nano /etc/ssh/sshd_config
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)