Connecting to a Raspberry Pi via SSH is a fundamental skill for any developer or hobbyist working with the device. While configuring the operating system, you often need to access the command line to install packages, manage services, or troubleshoot issues. The most direct way to authenticate into your headless server is by using an SSH password, providing a simple method to establish a secure remote session without needing a monitor or keyboard.
Understanding SSH Authentication Methods
Secure Shell (SSH) offers two primary authentication mechanisms for verifying your identity. The first method relies on a password, which is straightforward and requires only knowledge of the username and secret code. The second method utilizes cryptographic keys, which are more secure but involve a slightly more complex setup process. For users who prefer simplicity or are working in controlled environments, the password method remains a valid and widely used option.
Enabling SSH on Raspberry Pi OS
By default, recent versions of Raspberry Pi OS disable the SSH server to protect your device from unauthorized access out of the box. Before you can log in with an SSH password, you must explicitly enable the service. This can be done during the initial setup of the operating system or by using the configuration tools on an already installed system.
Using Raspberry Pi Imager
If you are flashing a fresh image to your SD card, the easiest approach is to use the Raspberry Pi Imager tool. After selecting your operating system and storage device, you can hold the Shift key and click "Next." This action opens the advanced options, where you can check the box to enable SSH and set up your username and password right away.
Activating SSH via Desktop
For systems already running, you can enable the service through the graphical user interface. Navigate to the Raspberry menu, go to "Preferences," and select "Raspberry Pi Configuration." In the interface tab, locate the "Interfaces" section, find "SSH," and select "Enable." You will be prompted to confirm the change, activating the daemon immediately.
Connecting with an SSH Password
Once the SSH server is active on your Raspberry Pi, you can establish a connection from another machine. On Linux and macOS systems, you can use the terminal, while Windows users can utilize PowerShell or third-party clients like PuTTY. The command structure is consistent across platforms, requiring the username and the IP address of the target device.
Default Credentials
When you first access your device, the username is typically pi . The default password for this account is raspberry . It is crucial to change this password immediately after your first login to prevent unauthorized access to your hardware. Security is paramount, especially when exposing the device to the internet.
Security Best Practices
While using an SSH password is convenient, it introduces certain vulnerabilities, primarily through brute-force attacks. Automated bots constantly scan the internet for devices with weak credentials. To mitigate this risk, you should implement strong, unique passwords that combine letters, numbers, and special characters.
Additional Protective Measures
Change the default password immediately upon setup.
Disable the pi user if possible and create a custom user account.
Consider changing the default SSH port from 22 to a higher number to reduce noise.
Utilize a firewall to restrict access to specific IP addresses.
Troubleshooting Connection Issues
If you are unable to connect to your Raspberry Pi via SSH, there are several steps to diagnose the problem. First, verify that both devices are on the same local network. You can check the IP address of your Pi by looking at your router's connected devices list or by connecting a monitor and keyboard to run hostname -I .