Posted on Leave a comment

How to ssh into your Raspberry Pi

Raspberry Pi ssh connection

Time needed: 5 minutes

If you need to take control over your Raspberry Pi remotely, without having the need to have a desktop environment, an SSH connection is a fast, easy and secure solution. This tutorial will guide you how to establish an ssh connection between your Raspberry Pi and your computer.

A Secure Shell (SSH) is a network protocol that allows you to send commands to your Raspberry Pi remotely. As the Raspberry Pi is often used as a server, it is very handy to be able to communicate from your desktop to your Pi without having to connect a display and keyboard. If you want more information about ssh, visit the ‘Secure Shell’ Wikipedia page.

With an SSH connection you’ll have access to your Raspberry Pi through a ‘Terminal window’ environment. For quite some applications this type of connection will be enough. However, connecting via SSH doesn’t allow a remote desktop environment, which could be necessary for some applications. Have a look at our tutorial ‘How to access your Raspberry Pi with a remote desktop connection‘ if you want to know how to setup a remote desktop connection with your Pi.

Let’s start to setup the ssh connection now …

  1. Enable ssh on your Raspberry Pi

    Before being able to access your Raspberry Pi via an ssh connection you need to enable the ssh interface at your Pi first. If you try to setup a ssh connection without having enabled ssh, you’ll get a ‘Connection refused’ message. There are 2 easy ways to enable ssh :

    a. Method with display or with desktop environment
    On your Raspberry Pi, open: applications menu > Preferences > Raspberry Pi Configuration as shown in the picture below.

    Raspberry Pi raspi-config
    Once the Raspberry Pi Configuration window opened, click on the tab “Interfaces”. Select here “Enabled” in front of SSH.

    Raspberry Pi enable SSH
    b. Method without display or without desktop environment
    If you don’t have a display or if you installed the Raspberry Pi OS Lite version (without desktop environment) you need to remove the SD-card from you Pi and insert it into your computer. Don’t worry if an error message appears, just ignore it.

    Add now a new blank file named ‘ssh’ in the ‘boot’ directory as you can see below. Make sure there is no extension as ‘.txt’ for example. And leave the content of the file empty.

    Raspberry Pi boot ssh file
    That’s it for the second method. You can now remove the SD-card from your computer and put it back into your Raspberry Pi. The ssh-functionality will be enabled on the next boot.

  2. Find out your Raspberry Pi’s IP address

    Be sure your Pi is connected to your LAN before continuing with the next step.

    a. Method with display or with desktop environment
    You can find the IP address by hoovering (do not click) over the network icon (right upper corner of your screen).

    raspberry pi network icon IP address
    b. Method without display or without desktop environment
    If you don’t have a desktop environment, you’ll have to search your Pi’s IP-address into the web app of your router (look for attached devices or something similar). And if you don’t have access to your router, you can use a tool like ‘Advanced IP Scanner‘ to see the used IP-addresses of your network.

  3. Open a terminal window or command prompt on your computer and ssh into your Raspberry Pi

    OK, we are ready now to establish an ssh connection from any computer connected to the same LAN as your Pi. For this, open a Terminal window (for Mac and Linux) or a Command Prompt window (for Windows 10 and 11 systems). And enter the following command :
    ssh pi@192.168.X.XXX
    The default username is ‘pi’, replace it if you changed the username.
    And replace the X.XXX with the actual IP address of your Pi.

    ssh first connection message
    The first time you connect to your Pi, you’ll get a warning message as shown above. In essence it tells you that you never connected to this server and asks you if it’s OK to continue. Just enter ‘yes’.

    Then you’ll be asked for a password. The default password for the user ‘pi’ is ‘raspberry’.

    ssh connected to Raspberry Pi
    That’s all. You can now access your Pi remotely in the same way you would open a terminal window directly on your Pi.

Remarks

  • To close your ssh-session properly, just type ‘exit’.
  • If your password is still the default password ‘raspberry’, your Raspberry Pi is really vulnerable (we strongly recommend to change you password ASAP).
  • If you try to setup a connection with an IP address you previously used for an earlier ssh connection, you’ll get an error message. This can be the case when you replace your Pi with another one and want to keep the same IP address for example. Solve this issue by deleting the line beginning with the IP address you want to use in the ‘known_hosts’ file. This file is stored on your C-drive. On my Windows 10 computer this file is located in the directory ‘C:\Users\Frederic\.ssh’.

How useful was this post?

Click on a star to rate it!

Average rating 4.5 / 5. Vote count: 8

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Leave a Reply

Your email address will not be published. Required fields are marked *

How useful was this post?

Click on a star to rate it!

Average rating 4.5 / 5. Vote count: 8

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

find out more products

Be the first to be informed about our latest tutorials and products by subscribing to our Newsletter

freva.com respects your privacy. Read our privacy policy on how we handle your personal information.