What is SSH?
The SSH protocol (also referred to as Secure Shell) is a method for secure remote login from one computer to another. It provides several alternative options for strong authentication, and it protects the communications security and integrity with strong encryption.
In our case we use our Desktop/Android device to logic to our Raspberry Pi remotely.
What will be covered?
- STEP 1: Download and setup Raspbian OS
- STEP 2: Enable SSH
- STEP 3: Connect to a network(wifi or LAN)
- STEP 4: Find the IP address of your Pi
- Final STEP: SSH login
STEP 1: Download and setup Raspbian OS
Note:Skip this step if you have already setup the Raspbian in pi beforehand.
- Next, download and install BalenaEtcher from here.
- Insert SD card to your computer and open BalenaEtcher .
- Select the raspbian image you downloaded earlier.
- Select your SD card
- Finally click on Flash!
It will take some time(Have patience or a cup of tea :P) to complete the Flashing process.
Finally This part is done!!
STEP 2 : Enable SSH
- First, remove and reinsert SD card to the computer once it is flashed.
In Linux :
Simply open a terminal and create a file named “ssh” in the boot directory of the SD cardby using the below command
nano ssh
In Windows:
- First, open the “boot” Directory from “This PC“.
- Next,Create a new “text document” like this in the “boot” directory named ssh
- Now we need to remove the extension of this file i.e from “ssh.txt” to “ssh”
- For this go to the view tab and check the checkbox “File name extensions” under Show/hide.
- Now,your file will look like this(Extension is displayed along with file name)
- Next just rename the file and remove the extension.
- Once done the file type will change to “File” from “Text Document”
That is it. With the next boot, SSH will be enabled.
STEP 3: Connect to a network(wifi or LAN)
First Method -Using LAN or Ethernet: In this method just connect your Pi to your router using an ethernet cable and power on the Pi. This will automatically connect your Pi to your local network.
Second Method Using Wifi: For this, we need to add another file inside the “boot” directory with the file name “wpa_supplicant.conf“
- Now open this file “wpa_supplicant.conf” with any text editor(i used notepad) and type the following and save it:
country=IN update_config=1 ctrl_interface=/var/run/wpa_supplicant network={ scan_ssid=1 ssid="Replace with your wifi name/SSID" psk="Replace with the wifi password " }
Country Code should be set using the ISO/IEC alpha2 code for the country.
This part is done !!
STEP 4: Find IP address of your Pi
To connect to your Raspberry Pi remotely, you need two things (we’ll help you find them):
- Its IP address on the local network
- An SSH client (SSH is a communication protocol between machines)
First power on the pi and wait for few seconds for the pi to boot up.
Next, we need to find the IP address of pi on your network. For this we can use any method
I use an app called Network Scanner to find the ip address.(playstore link)
Final Step :SSH login
Now open Cmd in windows or Terminal in linux and type:
ssh pi@192.168.31.6
Here my IP address was “192.168.31.6”.Replace with your IP address.
- Type yes and press Enter.
- Now enter the password as “raspberry”.[This is the default password.]
Note: when you type the password it is not visible on the screen .This is normal no need to worry.just type it and press enter.
- Now you have access to the command line of your Raspberry Pi remotely from another computer or device on the same network using SSH.
That’s it !! You have successfully connected via SSH into Pi.