Connect with SSH

SSH, or Secure Shell, is a cryptographic network protocol used to securely connect to remote computers or servers over an unsecured network, such as the internet. It provides strong encryption to protect data and communication between the client and the remote machine, allowing users to execute commands, manage files, and perform administrative tasks safely. SSH is commonly used for remote administration and secure file transfers.

Establishing a SSH Connection

Once your Raspberry Pi is plugged in and powered on, it is essential to give it about a minute to fully boot up. Ensure your Raspberry Pi and your computer are on the same local network, as this is necessary for establishing the SSH connection.

Connecting to Raspberry Pi OS via SSH

After the Raspberry Pi has booted, launch your terminal on your computer and execute the following command to initiate the connection:

ssh <USERNAME>@<HOSTNAME>.local

In the command above, you need to replace both <USERNAME> and <HOSTNAME> with the specific values you configured during the initial setup of your Raspberry Pi. For example, if your username is iot and the hostname you assigned to the Raspberry Pi is iotnode (within the .local domain), the command would look like this:

ssh iot@iotnode.local

First-Time Connection

When connecting for the first time, you will likely see a security prompt similar to:

The authenticity of host 'iotnode.local (192.168.x.x)' can't be established.
Are you sure you want to continue connecting (yes/no)?

Type yes and hit Enter. This adds your Raspberry Pi’s SSH key to your computer’s list of known hosts, preventing the message from appearing in future connections.

Entering Your Password

Once the connection is established, you will be prompted to enter the password you set for the username on your Raspberry Pi. After entering your password and pressing Enter, you should be greeted by a welcome message and the command prompt of your Raspberry Pi.

Troubleshooting SSH Connection Issues

In some cases, you may encounter issues connecting to your Raspberry Pi via SSH. Here are a few common troubleshooting steps:

  1. Ensure SSH is enabled on your Raspberry Pi: If you have not enabled SSH during setup, you can do so by connecting a keyboard and monitor to your Pi, running sudo raspi-config, and navigating to Interfacing Options → SSH.
  2. Verify the hostname: Ensure that the hostname of your Raspberry Pi is correct and that you are typing it exactly as configured. If unsure, you can check the hostname by running hostname on your Raspberry Pi.
  3. Check network connectivity: Both your Raspberry Pi and your computer must be connected to the same local network. You can check if your Raspberry Pi is online by using a network scanning tool like nmap or by trying to ping the device using its IP address.
  4. Use the IP address instead of the hostname: If .local domain resolution is not working, you can use your Raspberry Pi’s IP address instead. For example, if your Raspberry Pi’s IP is 192.168.1.100, you would connect using:
    ssh iot@192.168.1.100