
Raspberry Pi for Secret Agents - Second Edition
By :

Pretty much all the pranks and projects in this book will be done at the command line while being remotely logged in to the Pi over the network through SSH. Before we can do that, we need to be sure our Pi is reachable and we need to know its IP address. First we'll look at wired networks, then at Wi-Fi.
So you've plugged an Ethernet patch cable into the Pi and connected it to your home router, now what? Well, there should be all kinds of blinking lights both around the port of your router and on your Pi. The next thing that needs to happen is for the router to assign an IP address to the Pi using Dynamic Host Configuration Protocol (DHCP). DHCP is a common service on network equipment that hands out unique IP addresses to all computers that want to join the network.
Let's have a look at the address assigned to the Ethernet port (eth0
) on the Pi itself using the following command:
pi@raspberrypi ~ $ ip addr show eth0
If your DHCP service is working correctly, you should see a line similar to the following output:
inet 192.168.1.20/24 brd 192.168.1.255 scope global eth0
The digits between inet
and the /
character is your Pi's IP address, 192.168.1.20
in this case.
If your output doesn't have a line beginning with inet
, it's most likely that your router lacks a DHCP service, or that the service needs to be enabled or configured. Exactly how to do this is outside the scope of this book, but try the manual for your router and search for dhcp.
For static address network setups without DHCP, see the Setting up point-to-point networking section in Chapter 5, Taking Your Pi Off-road.
The easiest way to set up Wi-Fi networking is to use the included WiFi Config GUI application. Therefore, we will briefly enter the graphical desktop environment, configure the Wi-Fi, and save the information so that the Wi-Fi dongle will associate with your access point automatically on boot.
If you have a USB hub handy, you'll want to connect your keyboard, mouse, and Wi-Fi dongle now. While it's fully possible to perform the following actions using only the keyboard, a mouse will be very convenient:
startx
to start the graphical desktop environment.If you're unsure about the Authentication type of your access point, pressing Scan might help you figure it out.
Adding an access point in Wi-Fi Config
To find out about the leased IP address of your Wi-Fi adapter (wlan0
), without having to enter the graphical desktop, use the following command:
pi@raspberrypi ~ $ ip addr show wlan0
You should see a line similar to the following output:
inet 192.168.1.15/24 brd 192.168.1.255 scope global wlan0
The digits between inet
and the /
character is your Pi's IP address, 192.168.1.15
in this case.
To obtain information about the associated access point and signal quality, use the iwconfig
command.
We will be using an application called PuTTY to connect to the SSH service on the Pi. The steps to be followed are:
putty-0.63-installer.exe
, since the file copy utilities will come in handy in later chapters.raspberrypi.
(with the trailing dot) instead of the IP address; try it and see whether it works.pi
and enter the password you chose earlier with raspi-config
.pi
. When you've had enough pranking for the day, type exit
to quit your SSH session.Both Mac OS X and Linux come with command-line SSH clients. Follow these steps:
/Applications/Utilities
on the Mac).[IP address]
with the particular IP address of your Pi that we found out previously:$ ssh pi@[IP address]
If your network provides a convenient local DNS service, you might be able to type raspberrypi
instead of the IP address try it and see whether it works.
pi
that you chose earlier with raspi-config
.pi
. When you've had enough pranking for the day, type exit
to quit your SSH session.Change the font size
Change margin width
Change background colour