How to Enable SSH on Raspberry Pi
4 min read
Secure Shell (SSH) is a cryptographic network protocol used for a secure connection between a client and a server. In the recent versions of Raspbian, the SSH access is disabled by default but it can be easily enabled.
In this tutorial, we’ll show you how to enable SSH on a Raspberry Pi board. Enabling SSH will allow you to remotely connect to your Pi and perform administrative tasks or transfer files.
We’re assuming that you have Raspbian installed on your Raspberry Pi.
Enabling SSH on Raspberry Pi Without a Screen
If you don’t have a spare HDMI display or keyboard available to hook up the Raspberry Pi you can easily enable SSH by placing an empty file named ssh ( without any extension ) into the boot partition.
To enable SSH on your Raspberry Pi perform the following steps:
- Power off your Raspberry Pi and remove the SD card.
- Insert the SD card into your computer’s card reader. The SD card will mount automatically.
- Navigate to the SD card boot directory using your OS file manager. Linux and macOS users can also do this from the command line.
- Create a new empty file named ssh, without any extension, inside the boot directory.
- Remove the SD card from your computer and put it in your Raspberry Pi.
- Power on your Pi board. On boot Pi will check whether this file exists and if it does, SSH will be enabled and the file is removed.
That’s all. Once Raspberry Pi boots up you can SSH into it.
Enabling SSH on Raspberry Pi
If you have an HDMI monitor plugged into your Raspberry Pi you can enable SSH manually from the desktop GUI or from the terminal.
Enabling SSH from GUI
If you prefer a GUI over the command line, perform the steps below:
Open the “Raspberry Pi Configuration” window from the “Preferences” menu.
Click on the “Interfaces” tab.
Select “Enable” next to the SSH row.
Click on the “OK” button for the changes to take effect.
Enabling SSH from the terminal
Open your terminal either by using the
Ctrl+Alt+Tkeyboard shortcut or by clicking on the terminal icon and start the
raspi-configtool by typing:
Navigate to “Interfacing Options” using key up or key down and press
Navigate to “SSH” and press
You will be prompted whether you like to enable the SSH server. Select “Yes” and press
The next window will inform you that the SSH server is enabled. Press
Entertop go back to the main menu and select “Finish” to close the raspi-config dialog.
Alternatively, instead of using
raspi-config tool, you can simply start and enable the ssh service with
sudo systemctl enable ssh
sudo systemctl start ssh
Connecting Raspberry Pi via SSH
To connect to Pi via SSH you will need to know your Raspberry Pi IP address. If you are running the Pi without a screen, you can find the IP address in your router’s DHCP lease table. Otherwise, if you have a monitor plugged in, use the ip command to determine the board IP address:
When you’ve found the IP address, you can connect to your Raspberry Pi from your computer. Windows users can use an SSH client like PuTTY.
Linux and macOS user have an SSH client installed by default, and can SSH into the Pi by typing:
pi_ip_addresswith the IP Address of your Pi board. If you have not changed the “pi” user password, the default one is raspberry.
When you connect through SSH for the first time, you will be prompted to accept the RSA key fingerprint, Type “yes” to continue.
Once you are logged into your Raspberry Pi you will be greeted with a message similar to the one below.
Linux raspberrypi 4.14.98-v7+ #1200 SMP Tue Feb 12 20:27:48 GMT 2019 armv7l The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. ...
If you are exposing your Pi to the Internet it is a good idea to implement some security measures. By default, SSH listens on port 22. Changing the default SSH port adds an extra layer of security to your machine by reducing the risk of automated attacks. You can also set up an SSH key-based authentication and connect without entering a password.
You have learned how to enable SSH on Raspberry Pi. You can now login to your board add perform common sysadmin tasks through the command prompt. Linux and macOS users can simplify their workflow by defining all SSH connections in the SSH config file.
If you have any questions, please leave a comment below.