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 in your computer. So in this article, I will show you how to SSH into Raspberry Pi.
Join the channel Telegram of the AnonyViet đ Link đ |
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.
passwd
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:
hostname -i
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:
sudo raspi-config
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:
nano /etc/ssh/sshd_config
Now look for this line:
#PermitRootLogin prohibit-password
Edit this line to:
PermitRootLogin no
Save and close the file by pressing Ctrl + X, then Y. Now you should restart the SSH server with this command:
/etc/init.d/sshd restart
There are other steps you can take to SSH server security more, so make sure your Raspberry Pi can take the risk.
Login 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 wrote down earlier, you can ssh into your Pi with the following command
ssh pi@[address]
For example, if your Raspberry Pi’s address is 192.168.0.200, the command would be:
ssh [email protected]
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.