Connecting via SSH

The Raspberry Pi was designed to make it very easy to get started by connecting a monitor, keyboard, and mouse.  But, what if you don't have access to the necessary peripherals or don't want to disconnect them from your main workstation? The answer? Secure Shell (SSH).  SSH is a network protocol that can be used for secure remote command-line login, and thankfully it's enabled by default if you are using the Raspbian Distro.

Hardware Connections

To connect via SSH, you only need connect your Raspberry Pi to power & to your network via an ethernet cable.  For this guide, I have loaded a fresh install of the 2014-09-09 release of Raspbian on my SD card, but if you have an older release of Raspbian already installed, it should work as well.

Finding Your Raspberry Pi's IP Address

You can plug in an Ethernet cable and the Pi will automagically DHCP and connect to the internet. Then you have to actually connect to the Pi. To find the IP address of your Raspberry Pi, there's a lot of options.

If you have neither, you can find the device using your router's control panel, or you can use nmap to search for devices that are accepting connections on TCP port 22, which is the port SSH uses.  I am not going to assume that you have access to your router's control panel, so I will show you how to use nmap to locate your Raspberry Pi's IP address.

If you are running Windows, head over to nmap.org for their Windows installation instructions.  If you are running Mac OS X, you can install using the executable installer, or by using a package manager like homebrew.

brew install nmap

If you are running a Linux distribution on your workstation, use your favorite package manager to install nmap, or visit the nmap.org downloads page for instructions on installing from source.

sudo apt-get install nmap

Once you have nmap installed, you are now ready to search for the IP address.  Using the terminal on Linux & Mac OS, or the command prompt on Windows, enter the following command.

nmap -p 22 --open -sV 10.0.1.*

If your local network is setup to use 192.168.1.* addresses, modify the command to match your network setup.

nmap -p 22 --open -sV 192.168.1.*

The output of nmap might seem intimidating, but here are a couple hints that should make it easier to identify your Raspberry Pi.  Look for a line that contains something like "OpenSSH 6.0p1 Debian".  Once you find that, navigate your way up a few lines to a line that starts with "Nmap scan report for...".  The IP address that follows that statement should be the IP of your Raspberry Pi!  In the example below, you can see that the IP address I'm looking for is 10.0.1.10.

$ nmap -p 22 --open -sV 10.0.1.*

Starting Nmap 6.47 ( http://nmap.org ) at 2014-12-17 11:47 EST
Nmap scan report for 10.0.1.10
Host is up (0.0056s latency).
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 6.0p1 Debian 4+deb7u2 (protocol 2.0)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 255 IP addresses (3 hosts up) scanned in 3.39 seconds

Connecting via SSH

If you are using Windows, you will need to install a SSH client like PuTTY to connect to your Raspberry Pi, but if you use Linux or Mac OS X, you are ready to connect.  The default user for logging into a fresh Raspbian install is pi, and the default password is raspberry.  If you are using PuTTY on Windows, enter the connection details into the session configuration window.

Replace the 10.0.1.10 address with the IP address of your Raspberry Pi.

Under the Connection -> Data menu, enter pi into the Auto-login username field, and click the Open button at the bottom of the window.

If you are using Linux or Mac OS X, enter the following command into your terminal.

You will then be prompted to verify that you want to connect to the host.  Type yes to confirm, and hit the Enter/Return key on your keyboard. You should only be prompted to confirm that you want to connect the first time you try connecting.

$ ssh [email protected]
The authenticity of host '10.0.1.10 (10.0.1.10)' can't be established.
RSA key fingerprint is e8:e0:f0:09:7e:a4:81:42:44:30:65:f0:4f:b4:a6:a5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.1.10' (RSA) to the list of known hosts.

After that, you will be prompted for the password for the pi user.  Enter the default password of raspberry and hit the Enter/Return key.  If you have entered everything correctly, you should be logged into your Raspberry Pi via SSH!

[email protected]'s password:
Linux raspberrypi 3.12.28+ #709 PREEMPT Mon Sep 8 15:28:00 BST 2014 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Dec 17 14:01:23 2014 from 10.0.1.7
[email protected] ~ $ 
Last updated on 2015-05-04 at 04.27.57 PM Published on 2014-12-19 at 04.57.54 PM