JOURNEY OF RASPBERRY Pi
Part- 4 Discovery of Pi & connection using SSH
In this post we will see that how can we connect our laptop with Raspberry Pi without any display attached to it( of course both devices should be running in same LAN using WiFi or LAN Cable) . Pi is a low power device and it’s highly preferable over traditional Desktop/ Laptops for iOT projects or other means because of this same reason, so to actually utilize this feature we would want this device to run in isolation i.e, without connecting it to any tv, touch screen or laptop. So for now our target is to make a connection from our Pc / Laptop to Raspberry Pi but how do we do that? It’s very simple, we just need to scan our network to find out exactly which devices are connected to our network and we need to find out IP address of our Pi. When we talk about Network scanner NMAP is the first name which comes in mind first. If you are not aware of it, please visit the official site https://nmap.org and explore it.
If you are using Debian based os on your pc, you can issue below command to install nmap -
sudo apt-get install nmap
Assuming your local IP range is 192.168.1.0–254, below command will search and list all the devices which are connected to your Wi-Fi/ LAN -
sudo nmap -sP 192.168.1.0/24
Above command gives me below list of devices :
from the obtained result I got to know that these 5 devices are connected to same network and my laptop which performed this test is also one of them. Now we can follow 2 different approach to know which one of the connected devices is Raspberry Pi since it’s not obvious from the name. One approach can be to try connecting each IPs individually one by one and see the luck. Another approach would be to guess the device by its manufacturer, this requires you awareness and a little bit googling regarding listed manufacturer makes what type of device. I followed later approach since I know that the wifi adapter connected to my Raspberry is made by Shenzhen Four Seas Global Link Network Technology therefore the IP which I am looking for is 192.168.1.5.
In case if someone has missed it, default credential for DietPi os is as below -
username : root password : dietpi
To connect with Pi running on 192.168.1.5 we will have to issue below command -
ssh root@192.168.1.5
I have got prompt to enter password which assures me that my guess was right and I am connecting to correct IP address. I am able to login successfully into my Pi now, same can be seen in screenshot given below -
So we have finally connected our PC/ Laptop to Raspberry Pi running DietPi os using ssh. This way we will save some electricity by not using display device for pi and also we will be able to install softwares on Pi using laptop which will be a lot more comfortable than connecting keyboard, mouse and a display to Pi.
Conclusion
In this post we learnt how to get the IP address of Raspberry pi running in Local Area Network and connecting to it over SSH. In our next tutorial we will continue from here and will setup Nginx Web server on Pi running DietPi.