Configure Raspberry Pi and Remote Connect Using SSH
Requirements
- Completed Training Module 01: Choosing a Sensor
- Monitor
- Mouse
- Keyboard
- Wifi connection
- Personal Computer
- Operating Raspberry Pi set up as an interactive computer
Objective
In this module, we will connect our operating Raspberry Pi to our Wifi network. Afterwards, we will connect remotely to the Raspberry Pi from our personal computer using Secure Shell Protocol (SSH).
If this is the first time the Raspberry Pi you intend to use has been operated on, or you prefer to start from scratch, set up your Raspberry Pi using the Getting Started with your Raspberry Pi tutorial.
Getting Started
First, make sure your Raspberry Pi is properly connected to the Power Supply. Plug your power suppy into the port makred "PWR IN":
Next, plug in the keyboard...
Then, plug in the mouse...
Finally, connect your monitor...
Connect Raspberry to Wifi
With everything plugged into the Raspberry Pi, you should be able to access the desktop screen. To connect the wifi, access Network Manager via the network icon at the rightHand end of the menu bar. If you are using a Raspberry Pi with built-in wireless connectivity, or if a wireless dongle is plugged in, click this icon to bring up a list of available wireless networks.
The icons on the right show whether a network is secured or not, and give an indication of signal strength. Click the network that you want to connect to. If the network is secured, a dialogue box will prompt you to enter the network key:
Enter the key and click OK, then wait a couple of seconds. The network icon will flash briefly to show that a connection is being made. When connected, the icon will stop flashing and show the signal strength.
Obtain IP Address of Raspberry Pi
Now that you're Raspberry Pi is connected to your network, we will begin shifting our focus to your personal computer. However, to remotely connect to your Raspberry Pi, you will first need to obtain the IP Address associated your Raspberry Pi. Here are a couple ways to do this:
Desktop
If you still have access to the R-Pi's Desktop, Hover over the network icon in the system tray, and a tooltip will appear. This tooltip displays the name of the network you’re currently connected to and your IP address. Copy this down and save for later.
Remotely with mDNS
Raspberry Pi OS supports multicast DNS as part of the Avahi service.
If your device supports mDNS, you can reach your Raspberry Pi in the terminal of your personal computer by using its hostname and the .local suffix (as longa as both your computer and the Raspberry Pi are connected to the same network). The default hostname on a fresh Raspberry Pi OS install is raspberrypi, so by default any Raspberry Pi running Raspberry Pi OS responds to:
ping raspberrypi.local
If the Raspberry Pi is reachable, ping will show its IP address:
PING raspberrypi.local (192.168.1.131): 56 data bytes
64 bytes from 192.168.1.131: icmp_seq=0 ttl=255 time=2.618 ms
Copy this IP Address down
Remote Connect using SSH
You can access the terminal of a Raspberry Pi remotely from another computer on the same network using the Secure Shell (SSH) protocol.
This can only be done if SSH is enabled on the Raspberry Pi OS. If this is the first time the R-Pi is being used, you will need to enable it. Following these Enable the SSH server instructions.
To connect to an SSH server, open a terminal window on your computer and enter the following command, replacing the <ip address> placeholder with the IP address of the Raspberry Pi you’re trying to connect to and <username> with your username. If no username was setup, the devaul username is pi and the default password is raspberry
ssh <username>@<ip address>
@Example:
ssh pi@192.168.1.8
When the connection works, you will see a security warning. Type yes to continue. You will only see this warning the first time you connect.
Enter your account password when prompted.
You should now see the Raspberry Pi command prompt:
<username>@<hostname> ~ $
You are now connected to the Raspberry Pi remotely, and can execute commands.
Recap
Congratulations, in this module, you configured your Raspberry Pi to accept a remote connection from your personal computer using SSH. In the next module, we write a sample code to read our sensor and output to the terminal.