For remote maintenance via command line, an SSH connection to Raspberry Pi can be established. So How to enable ssh on raspberry pi? To do this, Raspberry Pi must be connected to the network via Ethernet or WIFI. In addition, SSH must be enabled.
Note: For security reasons, Raspbian SSH is disabled by default.
Deactivating SSH by default is easy to understand. By default, the user is set to “pi” and the password is “raspberry”. The problem with this is that if the user does not change the password after the initial startup, then anyone can connect to Raspberry Pi while the SSH is enabled and drive swindlers.
If the user activates SSH without changing the password, then it is his fault if someone else takes control of his Raspberry Pi.
- File “ssh” in the boot partition
- Enable SSH via “raspi-config”
- Enable SSH on the command line
Solution 1: File “ssh” in the boot partition
If you do not have the option to use Raspberry Pi via keyboard, mouse and screen, you can create an empty file named “ssh” on the SD memory card in the boot partition. If you do that with Windows, then you have to make sure that no file extension is added.
When Raspbian is started, SSH is activated and the file is deleted automatically.
Solution 2: Enable SSH via “raspi-config”
On the command line, enter the following command:
To enable SSH, follow the menu path “Interfacing Options / SSH”. Here you confirm the question with “Yes / Yes”
Solution 3: Enable SSH on the command line
The following solution is more complicated at first glance, opening the control of services on the command line. In other words, what works for SSH in this case also works for other services.
sudo systemctl start ssh
sudo systemctl stop ssh
SSH will start automatically in the future:
sudo systemctl enable ssh
SSH will NOT start automatically in the future:
sudo systemctl disable ssh
Indicates whether SSH starts automatically:
systemctl is-enabled ssh
Show status for SSH:
sudo systemctl status ssh
Show detailed status about SSH:
sudo systemctl show ssh
Build SSH connection to Raspberry Pi
To connect to a Raspberry Pi via SSH you need an SSH client and the host name or IP address of the Raspberry Pi. For computer systems with macOS and Linux, the SSH client is already integrated on the command line. Here you only have to call a terminal program.
Under Windows you also have to install an SSH client (eg PuTTY).
The next steps