Remote into your Raspberry Pi using SSH and PuTTY on Windows
Learn how to connect to a Raspberry Pi running Linux remotely from a Windows computer using Secure Shell (SSH) and the PuTTY client. This guide will show you how to set up an SSH server on your Raspbe …
Updated October 2, 2023
Learn how to connect to a Raspberry Pi running Linux remotely from a Windows computer using Secure Shell (SSH) and the PuTTY client. This guide will show you how to set up an SSH server on your Raspberry Pi, generate SSH keys, configure PuTTY for secure access, and finally connect to your Pi.
Raspberry Pi is a popular single-board computer used for various projects in education, home automation, and digital art. One of the most common tasks for any Raspberry Pi user is remote access from another device, such as Windows PC or Mac. In this guide, we will show you how to access your Raspberry Pi from a Windows computer using SSH (Secure Shell) and PuTTY client.
Step 1: Set up an SSH server on your Raspberry Pi
First, ensure that your Raspberry Pi is running a Linux distribution that supports SSH. The latest versions of Raspbian come with SSH pre-installed, so you don’t need to do anything if you are using the latest version. If not, you can enable SSH by following these steps:
- Open the terminal on your Raspberry Pi and type
sudo raspi-config
. - Navigate to Interfacing Options > SSH and select Enable SSH.
- Choose Finish and reboot your Pi when prompted.
Step 2: Generate SSH keys
SSH keys are a more secure way of authenticating yourself to the Raspberry Pi instead of using a password. To generate a key pair, follow these steps on your Windows computer:
- Open Git Bash (if you have it installed) or any other terminal emulator that supports SSH keys. If not, you can use PuTTYgen which comes with the PuTTY package.
- Type
ssh-keygen -t rsa
to generate a new RSA key pair. You will be prompted for a file path to save your private and public keys. Save them in a secure location. - Open your public key file (with a .pub extension) with a text editor and copy the contents.
Step 3: Configure PuTTY for secure access
PuTTY is a free SSH client for Windows that you can use to connect to your Raspberry Pi remotely. Follow these steps to set up PuTTY:
- Download and install PuTTY from the official website (https://www.putty.org/).
- Open PuTTY and enter your Raspberry Pi’s IP address or hostname in the Host Name field.
- Go to Connection > SSH > Auth, select your private key file in the Private key file for authentication field.
- In the category “Session,” save your configuration as a profile for easy access later (e.g., Raspberry Pi).
- Click Open to connect to your Raspberry Pi.
If you have not copied your public key to your Raspberry Pi yet, follow these steps:
- Log in to your Raspberry Pi using the default
pi
user and password (raspberry
). - Create a new file called
authorized_keys
in the.ssh
directory of thepi
user by runningtouch ~/.ssh/authorized_keys
. - Open the
authorized_keys
file with a text editor (e.g., nano) and paste your public key into it:nano ~/.ssh/authorized_keys
. - Save the changes and exit the editor.
- Set the correct permissions for the
authorized_keys
file by runningchmod 600 ~/.ssh/authorized_keys
.
Step 4: Connect to your Raspberry Pi from Windows
- Open PuTTY and select the profile you saved in step 3 (e.g., Raspberry Pi).
- Click Open to connect to your Raspberry Pi. You will be prompted for your username, password, or private key passphrase if you set one during key generation.
- Once connected, you can run Linux commands on your Raspberry Pi as if you were sitting in front of it!
Remember that when using SSH, it is essential to keep your system updated and secure. Be cautious about installing new software and services, and always use strong passwords or key pairs for authentication.