1 year ago

SSH: Remote control your Raspberry Pi

Remote control your Raspberry Pi from a PC, Linux or Mac computer using SSH

SSH (also known as ‘secure shell’) is an encrypted networking technology that enables you to manage computers from the command line over a network.

SSH is handy if you want to quickly connect to your Raspberry Pi from a terminal on another computer. It’s also ideal for lightweight distro installations that don’t have an interface. It’s especially useful when creating Internet of Things (IoT) projects, as these may be embedded and not require a desktop.

We’ve already looked at VNC (Virtual Network Computing), and Secure Shell offers a similar service. But while VNC shares the entire desktop, SSH works from the command line.

See also: VNC: Remote Control a Raspberry Pi desktop

Use SSH on a Raspberry Pi with PC, Windows and Linux

On Linux PCs and Macs, you don’t need to install any software to start using secure shell. Linux and Mac OS X have the command-line application installed by default; you can view its manual in the terminal using man VNC.

On Windows you will need to download a  client; the most commonly used one is called PuTTY. Download the PuTTY software from Simon Tatham’s website.

You’ll need to use the password for your Raspberry Pi to log in. For security reasons, we recommend changing the default password.

SSH uses an encrypted network, so it doesn’t send your password as plain text. More advanced users can control the encryption keys, using ssh-keygen. For now, we’ll look at setting up and using secure shell.

Step 1 Activate SSH in Raspbian

As of the November 2016 release of Raspbian with PIXEL, secure shell is no longer turned on by default. On your Raspberry Pi, choose Menu > Preferences > Raspberry Pi Configuration. Click on Interfaces and set SSH to Enabled. Click OK.

Step 2: Get your IP address

Connect your Raspberry Pi to a local network. Use a wireless network, or connect the Raspberry Pi directly to a router with an Ethernet cable. Open a terminal and enter ifconfig to find the IP address. With Ethernet, it’ll be the four numbers next to inet addr:, such as If you’re connected wirelessly, look for similar numbers under wlan0.

Step 3: Start SSH on Linux or Mac

On a Linux or Mac, open a terminal and enter ssh pi@youripaddress. On our network, that’s ssh pi@ The first time, you’ll get this message: ‘The authenticity of host (’) can’t be established. ECDSA key fingerprint is SHA256:’ followed by a long cryptographic hash of letters and numbers. It will say ‘Are you sure you want to continue connecting?’. Enter yes and press RETURN.

Step 4: Use PuTTY on a Windows PC

SSH with PuTTY on a PC

On a PC you’ll need to install PuTTY. Download the putty.exe file and click Run. The PuTTY Configuration window appears with basic options. Enter the IP address of your Raspberry Pi in the ‘Host Name (Or IP Address)’ field. Don’t change the ‘Port’ field. Click Open. You will get a PuTTY ‘Security Alert’ field. Click Yes. The terminal window displays ‘login as:’ Enter pi and press RETURN. Now enter the password for your Raspberry Pi.

Step 5: The command line

You will now see your usual command line replaced with pi@raspberrypi: ~$. You are now logged in and working on the command line from your Raspberry Pi. Enter ls and you’ll see python_games along with the other unique Raspberry Pi folders and files. You can create, edit, move, and work with files as if you were using a terminal on your Raspberry Pi.

Step 5: Exiting the shell

There are limitations over VNC. You can’t open programs with a graphical interface, so you’ll need to use command-line alternatives (such as nano or vim instead of Leafpad for text editing). It’s not as easy to share files using secure shell as it is with VNC, but for fast command-line editing, it’s hard to beat. Enter exit at the command line to finish

  • Jon Ross

    Excellent walk-through to get SSH up and running. Small typo in Step 5. First sentence; VNC should be replaced with SSH.

  • David

    SSH is even better with tmux or screen. With these tools your session will persist even if the SSH connection is lost. Just log back in with SSH and reconnect to your previous session with tmux or screen. Works great for long running processes.

  • mintslice

    And right up the top, “man VNC” should be “man ssh”

  • mintslice

    If you’re using SSH a lot, try using the ssh-copy-id command to save typing a password each time. It’s more secure too.

  • Scott

    Agreed. Use of key-based logins is strangely not very encouraged on the Pi, but it really should be. It takes two seconds to setup.

    The fact that the Pi is probably not your primary computer means that key logins make even MORE sense: from your main computer you can dispatch commands to be run on the Pi, without physically logging in and typing out the command. Those Pi tasks appear to run “as if they were local”. A windows user could even make a .bat script which contains some commands for the Pi. It’s a nice way to work.

  • Bernard_Lavilliers

    In order to activate SSH for a first boot without any additionnal screen or keyboard you can also add an empty file entitled ssh on your SD card in the boot folder.

  • Parichay Barpanda

    Can we use raspberry pi without configuring it first? Like the arduino? I do not have a hdmi cable so i can’t see the GUI or RPi. I have installed noobs in a SD card and now I want to run the raspberry pi from linux terminal itself.