After setting up the Raspberry Pi, you may not need to attach additional monitors to it. When maintenance tasks are needed, such as upgrades and reboots, you can use Secure Shell (SSH) instead of plugging it into your computer. So in this article, I will show you how to SSH into Raspberry Pi.
What is SSH?
SSH stands for Secure Shell. It allows you to remotely connect to a server or system from another device using encrypted communications.
The main benefit of SSH is data encryption. With less secure remote login protocols, such as FTP, everything is sent in plain text. A hacker could uncover those communications and record things like usernames and passwords. Since SSH is encrypted, hackers won’t be able to do so anymore.
Security issues before enabling SSH
Enabling SSH is easy, but you should also take care of a few issues. First, make sure that your Raspberry Pi is secure. By setting a password for the user account.
When you first set up your Raspberry Pi, you should change the user account password. If you haven’t changed your password, you need to do it now. Open terminal, then enter passwd command.
You will be prompted to enter your current password, then choose a new password.
View the IP address or hostname of the Raspberry Pi
You will also need to know the hostname or IP address of the Pi. Enter the following command in the terminal:
This command will provide the IP address for your Raspberry Pi. That address will usually start with 192.168. Record the address or hostname.
Next, we will enable SSH.
Method 1: Enable SSH via GUI
One way to enable SSH is through the Raspberry Pi graphical interface. Just click the Raspberry icon in the top left corner of the screen, then click “Preferences” and select “Raspberry Pi Configuration”.
In this app, click on the “Interfaces” tab and look for “SSH”. Click “Enable”, then click “OK” to close the application.
Method 2: Enable SSH from Terminal
Another method to enable SSH is from the terminal. Enter this command to enable the configuration tool for your Raspberry Pi:
Use the arrow keys on your keyboard to select “Interfacing Options”, then press the Enter key.
Select “P2 SSH” and press Enter.
When asked, “Would you like the SSH server enabled”, select “Yes”. Press Enter again at the confirmation box, “The SSH server is enabled”, select “Finish”.
Disable SSH Root login
After you’ve enabled SSH, there’s another optional thing you should do. Letting the root user SSH into your Raspberry Pi is a security risk, so I recommend disabling root login via SSH. Remember that you can always issue administrative commands from your regular user with sudo.
In your Terminal window, enter this command:
Now look for this line:
Edit this line to:
Save and close the file by pressing Ctrl + X, then Y. You should now restart the SSH server with this command:
There are other steps you can take to further secure your SSH server, so be sure to take the risk your Raspberry Pi can take.
Sign in to your Raspberry Pi from another computer
Once those steps are complete, you’re ready to log into your Raspberry Pi from any computer on the local network. With the IP address or hostname you recorded earlier, you can ssh into your Pi with the following command
For example, if your Raspberry Pi’s address is 192.168.0.200, the command would be:
The first time you access your Pi, you will be asked to accept the encryption key. Just press Y, you’ll connect and be prompted for your password. Once done, you will be logged into the Raspberry Pi and can perform any task you need.
In addition to giving remote commands, you can also use SSH for other purposes, such as tunneling traffic, transferring files, connecting remote file systems, etc. In addition, you can also block ads with Raspberry Pi here.