While you can run commands from the Terminal on your Pi, I prefer to SSH in and use my main computer to run through everything so I can use my main keyboard, mouse and monitor without needing to switch between two computers constantly! Here’s how you can connect to your Raspberry Pi via SSH.
Ah, the joys of SSHing onto a Raspberry Pi!
Firstly, in order to connect to your Raspberry Pi via SSH, you’ll need to be connected to the same network. Luckily, Raspberry Pi devices already contain an SSH client by default, so all you’re likely to need to do from the Raspberry Pi end is enable it, if it isn’t already enabled (it is enabled by default).
To enable SSH on your Raspberry Pi, open your terminal and enter in:
sudo raspi-config
Then using your keyboard, scroll down to ssh, hit <Enter> and then choose <Enable> within the “Enable or disable ssh server”.
There are a few ways you can find out your Raspberry Pi’s IP address:
Run the following command:
ifconfig
The result should contain something like the following, where 192.168.0.149
would be the IP address:
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 20:c9:d0:82:5a:9d
inet 192.168.0.149 netmask 0xffffff00 broadcast 192.168.0.255
Run the following command too:
hostname -I
If you don’t have a screen attached to your Pi but need a way to find out its IP address — try logging onto your router’s browser-based interface (usually either 192.168.0.1
or 192.168.1.1
) and looking through the list of connected devices. Sometimes, the Raspberry Pi will appear with the name “Raspberry Pi” which makes it easy to spot!
SSHing into your Raspberry Pi from a Unix based operating system like Mac OS or Linux is quite simple as you do not need to install anything to get started — they have an SSH client pre-installed and ready in your terminal.
By default, your credentials on your Pi are:
To SSH in, write the following into your terminal window, switching out pi with the username on your Pi if you’ve got a different user account set up (if you aren’t sure, chances are high that the username is pi). Switch out 192.168.0.31
with your Pi’s IP address:
ssh pi@192.168.0.31
Not sure if it’s the right IP address? You’ll get a “connection timed out error” if you enter the wrong IP address — if you see that error, it is a hint to double check the address.
When the SSH connection is successful for the first time, the terminal will show you a security/authenticity alert. Type in yes
to continue. After this point, this message won’t appear in future connections.
Once you allow it to connect, it will then ask you for the password. Enter in “raspberry”, or if you’ve changed the password to something custom, type that one in instead. On Unix systems, entering in a password won’t show asterisks or anything, just type it in and hit enter when you are done.
To connect to your Raspberry Pi via SSH on Windows, you will need to install a third-party application called PuTTY. You can download this from the PuTTY website. It will provide an .exe file for you to run and should run instantly.
When you open up the app, type the IP address of your Pi into the “Host Name (or IP address)” field and then click Open.
Not sure if it’s the right IP address? Similarly to the Mac/Linux steps above, you’ll get a “Network error: Connection timed out” if you enter the wrong IP address — if you see that error, double check the IP address.
When the SSH connection is successful for the first time, PuTTY will display a “PuTTY Security Alert” popup. Click yes to continue. After this point, this message shouldn’t pop up again.
It will then prompt you to log in, provide your username and password (as mentioned above, it is pi
and raspberry
by default).
From that point in both set ups — you’ll now see a Terminal window where you can run commands directly onto your Pi!
On Mac OS and Linux, you can quit by pressing Ctrl + D or on any of the operating systems, including Windows type in:
exit
Know other emerging tech enthusiasts who might want to read this too? Please like and share this post with them!
Comments
Setting up a Home VPN Server Using Your Raspberry Pi
[…] remotely. If you aren’t quite sure how to SSH into your Raspberry Pi, I have a short guide on how to SSH into a Raspberry Pi which might help! If you don’t have a static IP address set up on your Pi, I’d […]