Headless Raspberry Pi Setup
Ethernet with Static IP Address
If you do not want to use the serial terminal or want to be able to log in to your Raspberry Pi over a network connection, you can give your Pi a static IP address, connect it to your network (or to your computer via a crossover/Ethernet cable), and log in via SSH.
Set Up Static IP Address
Plug the micro SD card (with the flashed Raspbian image) into your Linux computer. Most modern versions of Linux should automatically mount both partitions (boot and rootfs). You will need superuser privileges to edit the files on rootfs. Open a command prompt and edit /etc/dhcpcd.conf in rootfs.
Navigate to the rootfs directory (wherever your Linux distro has mounted it):
Edit the dhcpcd.conf file:
sudo nano /etc/dhcpcd.conf
Scroll down to the bottom of the file and add the following lines:
Save and exit by pressing ctrl + x and y when asked if you would like to save.
In 2016, much of the Internet slowed to a crawl as a result of the IoT DDoS attack brought about by the Mirai botnet. In response to vulnerable IoT systems with default username and password logins, the Raspberry Pi Foundation decided to disable the SSH connection by default on all future releases of Raspbian. As a result, we now need to enable SSH so we can log in over a network connection. You can read more about the reasonings for this here.
Luckily, this is easy to do. With the SD card still plugged in, navigate to the boot partition and create a blank file named "ssh" in that directory.
Still in the console, enter the following commands:
You should see an empty file named "ssh" appear in the root boot partition.
Unmount the SD card from your host computer and insert it into the Raspberry Pi.
Configure Your Host Computer's IP Address
Plug an Ethernet cable into the Raspberry Pi and the other end into your computer. Technically, we should be using a crossover cable, but since the late 1990s, most computers are capable of automatically detecting and configuring for crossover.
Configure your host computer to have an Ethernet static IP address with the following properties:
IP Address: 192.168.4.1
Subnet Mask: 255.255.255.0
Default Gateway: 192.168.4.1
Connect Over SSH
Secure Shell (SSH) gives us a terminal into an operating system over a network and encrypts the traffic, giving us a level of security. Depending on your host operating system, you have a number of options available to you.
PuTTY is an easy-to-use SSH, Telnet, and Serial terminal client. Open PuTTY, and set the Host Name to
192.168.4.2 and Port to
Click Open. If asked about chaching a host key, click Yes.
Mac and Linux
The easiest way to connect to another computer over SSH is to use the ssh command line tool built into most distributions of Linux and Mac OS. Simply open up a terminal and type:
Update: Users may need to use
ssh pi@<"IP Address">, where
pi predefines the login username.
Once SSH connects, enter the default login credentials:
- Username: pi
- Password: raspberry
You should be presented with a command prompt, if all goes well.