+5 votes
104 views
Raspberry Pi: Set up SSH - this is how it works

in Hardware by (552k points)
reopened | 104 views

1 Answer

+3 votes
Best answer

Install SSH on the Raspberry Pi
Allow SSH access
Use SSH under Windows
Use SSH connection under Linux or macOS

You can control your Raspberry Pi from another computer via SSH. We'll show you how to set up and use the function..

image image

A version of Linux traditionally runs on a Raspberry Pi. In practice, this means that many functions on the Pi can be managed via the terminal, for example the installation of new programs or updates or server functions of the Pi. The advantage: It not only works directly on the Raspberry Pi, but also remotely, i.e. from another PC in the network. Secure Shell or SSH for short is used here. The protocol enables an encrypted connection to the Raspi and the execution of terminal commands from a distance. File transfers from and to the Pi can also be implemented via an SSH connection.

image
Apps like Termius for iOS even enable remote maintenance of the Raspberry Pi from the iPad.

The use of SSH is particularly practical when the Raspberry Pi is operated “headless”, i.e. without a mouse, keyboard and monitor. SSH is also so widespread that a number of clients are available for practically all systems. You can control the Raspberry Pi via Windows, Linux, macOS or - thanks to SSH apps - even from your iPhone, iPad or your Android smartphone. The setup of SSH on the Raspberry Pi is done quickly. We'll show you how to activate the appropriate server on the Pi and allow remote access.

Note: SSH poses a security risk if the RPi has access to the Internet. It is therefore essential to change the standard password using the command passwd ..

Install SSH on the Raspberry Pi

Current versions of Raspbian or most alternative Linux distributions come from the factory with an SSH server. All you have to do is activate it (see below). If you are using an older version of Raspbian or a distribution without a pre-installed SSH server, you can install this quickly. To do this, open a terminal on the Raspberry Pi and enter this command: sudo apt-get install ssh Now you just have to start the SSH server. To do this, enter this command: sudo /etc/init.d/ssh start So that you don't have to start the SSH server manually every time, you can also call it up automatically when booting. To do this, enter the following command in the Linux terminal: sudo update-rc.d ssh defaults The Raspberry Pi is now permanently equipped for SSH access.

Tip: Is it not possible to operate the RPi with a keyboard, mouse and monitor? Simply create an empty file named " ssh " in the boot directory on the SD card . The file has no file extension! Now start your Raspberry Pi, SSH is automatically activated and you should follow the further steps to change the password..

image
If there is not yet an SSH server on your Raspi, you can install it quickly.

Allow SSH access

For security reasons, SSH on the Pi is deactivated by default with Raspbian and most other Linux distributions. However, it is not a problem to switch on the protocol and allow connections. If you operate your Raspi with the standard distribution Raspbian, you can activate SSH access via the system settings. To do this, open the “ Settings - Raspberry Pi configuration ” menu in the Raspbian start menu . In this menu, switch to the “ Interfaces ” tab and switch the “ SSH ” item to “ Activated ”. After clicking on “ Ok ”, you have to restart the Raspberry Pi once to enable SSH access.

image
In this Raspbian system menu, activate SSH access on the Pi.

If you work on the Raspberry Pi on the terminal level, activate the SSH access via the Raspbian configuration program. To open it, enter this command: sudo raspi-config Here you open menu item 5 “ Interfacing Options ” using the arrow keys on the keyboard . Now navigate to point 2 “ SSH ” and answer the question whether you want to activate the service with “ Yes ”. Now restart the Pi using the command “ sudo reboot ”. Then the SSH connection to the Raspberry Pi works as shown below.

image
You can activate SSH access on the Pi in just a few steps via the terminal.

Note: For SSH access to the Raspberry Pi, you need to know the Pi's username and password . The default username is “pi”. You can change the user password in different ways. For example, you can change it in the Raspi-Config menu with point 1 “ Change password for the current user ”. On the graphical user interface, change the user password on the Pi in the configuration menu presented above .

Use SSH under Windows

Windows had to do without its own SSH client for a long time. Beginning with the Fall Creators Update from 2017, Microsoft integrated an SSH implementation based on OpenSSH into the new PowerShell command line. So just open PowerShell via the start menu and enter this command: ssh username @ IPAdressedesPi As already mentioned, the standard user name is “pi”. You can find out the IP address of the Raspis via your router, for example. On the Raspberry Pi itself, the terminal command “ifconfig” outputs the current network settings and thus also the IP address. When connecting for the first time, you have to confirm the SSH key of the Pi by simply typing “ yes ”. After entering the user password you can conveniently carry out remote maintenance of the Pis directly under Windows.

image
With a recent Windows 10, you can use SSH directly to connect to the Pi.

In older Windows versions or on Windows 10 systems that have not yet received the newer system updates, you have to use external programs for the SSH connection to the Pi. The most popular SSH client for Windows is PuTTY. The free program opens an SSH connection to your Pi (or any other SSH server, of course) in a terminal window. Simply enter the IP address of the Pis in the “ Host Name ” field , select “ SSH ” for “ Connection Type ” and click “ Open ”. In the window that now opens, enter the user name and password one. You can now operate the terminal of the Raspberry Pi from Windows. Of course, you can also use PuTTY under Windows 10 as an alternative to Powershell.

image
PuTTY is a very good SSH client for Windows.

Use SSH connection under Linux or macOS

If you work under a Linux distribution or with a Mac, the SSH connection to the Pi is much easier. Both systems come from the factory with an SSH implementation. Simply open the Linux or macOS terminal and enter the appropriate command. By default, for example, you connect to the Raspberry Pi with the following command via SSH: ssh username @ IPAdressedesPi Now you can let off steam on the Raspberry Pi command line, just like with Windows.

image
Linux and macOS are factory-equipped for connection to SSH servers.

by (3.5m points)

Related questions

+3 votes
1 answer
asked Nov 14, 2021 in Hardware by backtothefuture (552k points) | 81 views
+5 votes
1 answer
asked Dec 24, 2021 in Hardware by backtothefuture (552k points) | 225 views
+4 votes
1 answer
asked Nov 21, 2021 in Hardware by backtothefuture (552k points) | 136 views
+4 votes
1 answer
asked Jan 3, 2022 in Apps / software by backtothefuture (552k points) | 124 views
+3 votes
1 answer
asked Jan 3, 2022 in Security by backtothefuture (552k points) | 122 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users