How to use Raspberry Pi SSH

Raspberry Pi SSH is a way we’re able to communicate to the Pi over a network, so we no longer need to be physically located near the Pi.

Raspberry Pi SSH

SSH or secure shell for anyone who is unfamiliar with the term is a common cryptographic protocol for communication over networks. It allows us to be able to use command-line without actually being on the Pi.

This technology is fantastic for a lot of Raspberry Pi projects that don’t require you to be on the Pi itself.

SSH is super easy to use once you get it set up and running. If you need to access the Pi via SSH outside your home network then you will need to look at port forwarding.

Jump into our tutorial below to learn all about SSH and how you can set it up with the Raspberry Pi.

Equipment

The list below is the equipment that I have used in this guide.

Raspberry Pi

Keyboard

Mouse

Power Supply

Raspberry Pi Case

Ethernet Cord or Wifi dongle

Video

If you want to see how to set up SSH visually then check out my video below.

Like the video? Please subscribe or follow us on social so you can stay up to date on all the latest and greatest Raspberry Pi projects, guides and much more.

Enabling the Raspberry Pi SSH Server

Before we get started with learning how to SSH into the Raspberry Pi, we will first need to have Raspbian installed.

If you haven’t installed Raspbian, then check out my guide on installing NOOBS Raspberry Pi. This guide will take you through all the steps you need to do before you start this guide.

The Raspberry Pi SSH Setup requires us to use the raspi-config tool to allow SSH connections. To do this, we will need a keyboard, mouse and a screen for the Pi. Once we have done this, we no longer require any of these pieces of equipment.

1. First turn on and log in to the Raspberry Pi. (Remember default username is pi and password raspberry)

2. If you need the IP Address now would be a good time to get it. To do this simply type:

hostname -I

3. Now type the following command:

sudo raspi-config

4. Now in here go to Interfacing Options->SSH (Previously Advanced Options->SSH)

5. Enable SSH and reboot the Pi.

Now that we have enabled SSH we will need to connect from another computer.

Using Windows to SSH to the Raspberry Pi

If you’re a windows user, then this process is pretty straightforward. We will need to get a free application called Putty first and use that to connect to the Raspberry Pi SSH.

1. To SSH on windows, we will need an additional tool called Putty. You can download putty here.

2. Download the putty.exe under “For Windows on Intel X85”

3. Now once that is installed load the putty.exe

4. In this screen, we will need to input the IP of the Raspberry Pi into the Host Field.

5. The port should be 22

6. Now click on open

7. You will now see a prompt with a security alert, just click yes to this.

8. Now login with the default username pi and password raspberry. (Unless you have already changed this)

Raspberry Pi Putty

You’re now able to connect to the Pi and send commands remotely rather than needing to be at the Pi itself.

Using a Mac to SSH to the Raspberry Pi

To connect to the Raspberry Pi SSH on Mac or Linux is very easy all we need to do is connect using the terminal.

If you’re using a Mac, then we will be able to use the terminal to connect. If you’re using a Mac, this is found under utilities within the applications folder.

1. First, open the terminal.

2. Replacing 192.168.1.103 with your own Raspberry Pi IP address issue the following command.

ssh pi@192.168.103

3. You will now receive a security warning type yes.

4. You should now see a prompt for the password for the user pi. The Raspberry Pi default password is just raspberry. (I highly recommend changing this)

5. You should now be able to control the Raspberry Pi through the terminal.

Raspberry Pi Mac SSH

Troubleshooting

If you’re having trouble trying to get this to work here are a few tips you can try to get the connection to work.

  • “I am getting a connection error”
  • Ensure you have the correct IP address and you have also enabled SSH in the raspi-config
  • Make sure the Pi is connected to the same network as you are on. (Unless of course you have setup port forwarding and connecting outside the network)
  • “I am getting access denied”
  • Make sure you are using the correct password, the default is raspberry but remember you may have changed it earlier.

I hope this guide has shown you how to SSH to the Raspberry Pi. However, if you still have trouble feel free to drop us a comment below.

23 Comments

  1. Keagan on

    Is there a way to set up ssh headless?

    1. Emmet on

      Hi Keagan,

      If you create a file called “ssh” on the root of the SD card the Raspbian operating system will detect it and automatically setup SSH.

      Cheers

  2. Ted Davis on

    In all this HowTo’s, why don’t you have at least rpi to rpi install walk throughs if not command line linux?

    1. Emmet on

      Hi Ted,

      Connecting between two linux systems is a rather simple process, in fact the “mac” method that is currently mentioned in the tutorial is relevant for the Linux as well.

      We plan on updating this guide to better reflect this in the near future.

      Cheers,
      Emmet

  3. Sean on

    Just something to note, I was able to work on my Pi by hooking onto ethernet and then accessing my router to find the Pi’s IP before ssh; beforehand while setting up the SD card I made sure to make an empty “ssh” file before I ejected it. So with that I could theoretically set up headlessly through and through.

  4. Morten on

    Hello Gus.

    Thanks for all the guides, i’m trying to access my PI on my mobile (not from the local network). i forwarded port 80 to the PI and then tried to connect from the external IP address but i get this error:

    “Connecting to xx.xx.xx.xx port 80, please wait….
    Failed to connect to xx.xx.xx.xx: Connection refused.”

    i got my PI as an always on torrent box + NAS and it works perfectly, also the access from another computer etc.

    Regards
    Morten

    1. Jonathan on

      Did you enable ssh of the rpi

  5. Sav on

    What is generally range of raspberry pi IP address ???
    Any idea ?

    Thanks

    1. Gus on

      Whatever your router/DHCP server can assign to it, if you’re trying to find out the actual IP address of the Pi then the command hostname -I will return it.

  6. Simon on

    And another option with Windows 10 now is to use the “Bash on Ubuntu on Windows” if you have that installed (enable in Windows Features | Windows Subsytem for Linux (Beta))

  7. Simon on

    Just a quick comment regarding recent updates to Raspbian (inc. Jessie) where SSH is disabled by default.
    When you first setup a Pi from an image file, if you, like me, don’t have the peripherals (keyboard/mouse/monitor) around, putting a file (even an empty one) called ssh in /boot will enable SSH on boot up meaning you can do everything “headless”.
    I haven’t explained any further because if what’s above doesn’t make sense to you, you should probably be setting your Pi up with the peripherals rather than “headless” and blind (I do not intend any disrespect to anyone by that comment)
    Cheers
    Simon

  8. Nix on

    I am new to raspberry Pi, using raspberry pi 2 model b, after installing raspbian-jessie, and entering login:pi and password:raspberry , getting error accces denied on putty.

  9. Mike G. on

    Your instructions on where to find the option to enable SSH is wrong. Instead of being under “Advanced Options”, the setting is found under “Interfacing Options”.

    1. Gus on

      They were correct, Raspbian has updated recently and changed the location. I will update the tutorial so it’s up to date with the latest version.

  10. joe reid on

    i am a huge fan of your guides , but with all due respect this thread should be entitled ” how to connect to your pi remotely ” not ” how to control your pi remotely ” , i have connected no probs but i haven’t a clue how to access the browser or open files or play videos or in fact do anything with pi when using command box ?

  11. Brendan Brooks on

    I’m getting an access denied error message. I tried changing the password on the pi using sudo passwd, but I’m still receiving the error. Any ideas?

  12. RLPendergast on

    Thanks.

  13. RLPendergast on

    Hi, Your presentations are excellent both in content and clarity.

    However, I need to know, how do I reboot or shutdown the RPi from the remote terminal? the screen say I am not authorized and use (pi) or root, but I am not sure what that means and using these two choices with reboot or shutdown -h now did not work.

    Thanks
    rlp

    1. Gus on

      The command sudo reboot should reboot your Pi from the remote terminal.

      Let me know if that helps!

  14. Mike on

    Any advice when getting “Network Error: connection timed out.”? I’m new to all this and have found that port 22 may be blocked but not too sure how to change that on my pi. Could this me correct? Also, what else could be the problem? Any ideas/advice would be appreciated.

    1. Gus on

      If your connection is timing out then either the port 22 is blocked, you’re connecting to the wrong IP or you have SSH disabled on the Pi.

      To enable it on the Pi you need to do the following:

      In the command line: sudo raspi-config

      This will open up settings. Go to Advanced Options and then SSH.
      Enable SSH then exit and reboot the Pi.

  15. Will on

    We were able to get the surveillance camera to work on the local network but am unable to access it outside the network. Any tutorials on this?
    Thanks.
    Will

    1. Gus on

      Hi Will,

      If you follow my port forwarding tutorial this will help you with allowing outside access to it. You can find the full tutorial here: http://pimylifeup.com/raspberry-pi-port-forwarding/

      I recommend using a random port for the external port but the internal port will need to 80.

Leave a Reply

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