Edit 1/1/2019: Since this answer continues to be popular, going to incorporate a change per bigjosh's comment. Around April 2017, Raspbian introduced a security change that no longer starts the SSH server by default (see this blog post). To enable the SSH server on boot, create a file named ssh
on the boot partition of the Pi's SD card prior to trying these instructions.
Using a Macbook Pro (any modern laptop/desktop will do), a Pi, and a clean, unbooted SD card with Raspbian on it, here's what I did:
On first boot, the Pi will actually start an SSH server available on the ethernet port. But, it's pretty much inaccessible if the Pi does not have an IP address. By default, it does not. It will activate a DHCP client to contact a router for an IP. Plugging the ethernet from the Pi into the computer will cause the Pi to ask for an IP. By default, consumer computers do not respond to this query. The first step is to activate a DHCP server on the computer. For my setup, I used dnsmasq installed in a Debian virtual machine that I had created for another project. The VM is not required, as dnsmasq will run just fine on a Mac (installable from MacPorts or source) or Linux computer natively. I believe there are some DHCP servers that run on Windows, but I am not sure. You could also plug the Pi into a wireless router with the same effect, except you wouldn't have to set up an DHCP server because almost all consumer wireless routers have this built in (you can probably skip the next paragraph if you are using a router).
Once the DHCP server is running, connect the Pi to the computer's ethernet and power it up. In the log file/console output, you should see something like this:
dnsmasq-dhcp[2358]: DHCPREQUEST(eth2) 10.79.26.137 ac:87:xx:xx:xx:xx
dnsmasq-dhcp[2358]: DHCPACK(eth2) 10.79.26.137 ac:87:xx:xx:xx:xx Maxwell
dnsmasq-dhcp[2358]: DHCPDISCOVER(eth2) b8:27:xx:xx:xx:xx
dnsmasq-dhcp[2358]: DHCPOFFER(eth2) 10.79.26.148 b8:27:xx:xx:xx:xx
dnsmasq-dhcp[2358]: DHCPREQUEST(eth2) 10.79.26.148 b8:27:xx:xx:xx:xx
dnsmasq-dhcp[2358]: DHCPACK(eth2) 10.79.26.148 b8:27:xx:xx:xx:xx raspberrypi
Explanation and what we're looking for here: The first two lines are my laptop (Maxwell) connecting to the DHCP server. Since the laptop recognizes the DHCP server, it requests an IP that it has had in the past: 10.37.27.137. This can be confirmed by looking at the network settings of your computer (for me, it showed up in System Preferences / Network in OS X). The DHCP server then gives my computer it's requested IP since it's not a conflict (DHCPACK
, dhcp-ack[nowledgement]). The next three four are related to the Pi: It first sends a DHCPDISCOVER
to find any DHCP servers (if any). Dnsmasq then offers it a new IP. The Pi accepts it (DHCPREQUEST
), and then the server confirms the IP in its database and actually gives the IP to the Pi. I know I've found the right entry because the final hostname listed in the DHCPACK
is "raspberrypi". Make a note of the IP address that the DHCP server gave the Pi (mine is 10.79.26.148).
If you connected the Pi to a router instead of a computer, look in the router's web interface for a list of DHCP clients, or a list of computers connected to the network. Most routers have this somewhere, even if they don't all call it the same thing. Look for a computer named "raspberrypi", and make a note of its IP address.
Once you have an IP for the Pi, you can connect to it with the SSH client of your choice. For Mac/Linux/UNIX, you can just open a terminal and type ssh pi@IP_ADDRESS
where IP_ADDRESS
is the IP of your Pi that you found earlier. Windows users can use Cygwin, MobaXterm, or PuTTY. If you got the IP right, you should see something like this:
$ ssh pi@raspberrypi
The authenticity of host 'raspberrypi (10.79.26.148)' can't be established.
ECDSA key fingerprint is 6c:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'raspberrypi,10.79.26.148' (ECDSA) to the list of known hosts.
pi@raspberrypi's password:
Since I had not connected to the Pi before, I had to accept the ECDSA key to continue. The default password, as stated in earlier answers here and in the official documentation, is raspberry
. Now, we are logged in to Raspbian over SSH, and can do things. You should see this now on the SSH console:
Linux raspberrypi 3.18.5+ #744 PREEMPT Fri Jan 30 18:19:07 GMT 2015 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.
NOTICE: the software on this Raspberry Pi has not been fully configured. Please run 'sudo raspi-config'
pi@raspberrypi ~ $
Now, as per the MOTD prompt, you need to run sudo raspi-config
which brings you to the same configuration window you would see if you had booted it up with HDMI. Among other things here, you should enable the SSH server. After configuring it, you can use this same setup to reconnect to the Pi over ssh again after the reboot.
Sources: my own experience.