Book Image

Raspberry Pi for Secret Agents

By : Stefan Sjogelid
Book Image

Raspberry Pi for Secret Agents

By: Stefan Sjogelid

Overview of this book

Ever wished you could play around with all the neat gadgets your favorite spies use (like James Bond or Michael Westen)? With the introduction of the remarkable Raspberry Pi and a few USB accessories, anybody can now join in on the action.Discover how to turn your Raspberry Pi into a multipurpose secret agent tool! Through a series of fun, easy-to-follow projects you'll learn how to set up audio/video surveillance, explore your Wi-Fi network, play pranks on your friends, and even learn how to free your Raspberry Pi from the constraints of the wall socket.Raspberry Pi for Secret Agents starts out with the initial setup of your Raspberry Pi, guides you through a number of pranks and secret agent techniques, and then shows you how to apply what you've learned out in the real world. Learn how to configure your operating system for maximum mischief and start exploring the audio, video, and Wi-Fi projects. Learn how to record, listen, or talk to people from a distance and how to distort your voice. You can even plug in your webcam and set up a motion detector with an alarm, or find out what the other computers on your Wi-Fi network are up to. Once you've mastered the techniques, combine them with a battery pack and GPS for the ultimate off-road spy kit.
Table of Contents (12 chapters)
Raspberry Pi for Secret Agents
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Accessing the Pi over the network using SSH


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.

Wired network setup

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 going on, both around the port of your router and the three LAN LEDs 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.

Wi-Fi network setup

The easiest way to set up the 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:

  1. Type startx and press the Enter key to start the graphical desktop environment.

  2. Double-click on the WiFi Config icon located on the desktop.

  3. From the Network drop-down menu, select Add.

  4. Fill out the information for your access point and click on the Add button.

  5. Your Wi-Fi adapter will associate immediately with the access point and should receive an IP address as listed under the Current Status tab.

  6. From the File drop-down menu, select Save Configuration.

  7. Exit the application and log out of the desktop environment.

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.

Connecting to the Pi from Windows

We will be using an application called PuTTY to connect to the SSH service on the Pi.

  1. To download the application, visit http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html.

  2. Download the all-inclusive windows installer called putty-0.62-installer.exe, since the file copy utilities will come in handy in later chapters.

  3. Install the application by running the installer.

  4. Start PuTTY from the shortcut in your Start menu.

  5. At the Host name (or IP address) field, input the IP address of your Pi that we found out previously. 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 if it works.

  6. Click on Open to initiate the connection to the Pi.

  7. The first time you connect to the Pi or any foreign system over SSH, you'll be prompted with a warning and a chance to verify the remote system's RSA key fingerprint before continuing. This is a security feature designed to ensure the authenticity of the remote system. Since we know that our Pi is indeed our Pi, answer yes to continue the connection.

  8. Login as pi and enter the password you chose earlier with Raspi-config.

  9. You're now logged in as the user pi. When you've had enough pranking for the day, type exit to quit your SSH session.

Connecting to the Pi from Mac OS X or Linux

Both Mac OS X and Linux come with command line SSH clients.

  1. Open up a Terminal (located in /Applications/Utilities on the Mac).

  2. Type in the following command, but replace [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 if it works.

  3. The first time you connect to the Pi or any foreign system over SSH, you'll be prompted with a warning and a chance to verify the remote system's RSA key fingerprint before continuing. This is a security feature designed to ensure the authenticity of the remote system. Since we know that our Pi is indeed our Pi, answer yes to continue the connection.

  4. Type the password of the user pi that you chose earlier with Raspi-config.

  5. You're now logged in as the user pi. When you've had enough pranking for the day, type exit to quit your SSH session.