Monday, 28 September 2015 14:54

Raspberry Pi setup without a Display

Written by 
Rate this item
(1 Vote)

No monitor connected to your Pi, No Problem!

Easy Step-by-step illustrated guide to setting up a raspberry pi without a monitor, from beginning to end

As long as you are on the same network as the raspberry pi, we can locate the IP address, and remotely configure it from our laptop or pc, without the need of another display.

Here's what you'll need

  • Pi connected on the same network as you
  • Access to your router's web interface or we'll scan the network from our pc
  • SSH client software (Putty, or through the linux command line)
  • Coffee and doughnuts

 

Plug in and go

Plug in your SD card into the Raspberry Pi, no SD card setup yet?  Check out my guides

Write a RaspBerry Pi SD Card In Linux Command Line

or

Write a Raspberry Pi image to an SD card in Windows

Once you have an SD card inserted into your Pi, Connect up a power supply and plug it in to your network

 

Connecting to your Pi with the hostanme

By default, most images you'll be running on the Raspberry Pi will have the default hostname of raspberry.  Depenidng on your working computer and the network your'e on, you may be able to access the Pi with only the hostname (instead of the IP address).  You can SSH into your pi (using the terminal or software like putty) using the hostname or hostname.local

ssh pi@raspberry

or

ssh This email address is being protected from spambots. You need JavaScript enabled to view it.

If you are able to connect using the hostname, you can use the command ifconfig, to find the Pi's local IP address

ifconfig

 

Finding the Raspberry Pi on the network

If you cannot access the Raspebrry Pi with the hostname alone, you will need to find the IP address.  This is the most difficult step, but I'll walk you through it.  By default, your network router will assign an IP address to the raspberry pi automatically.  We need to find that address.  There are several ways to do this, we'll discuss two different ways to finding your pi on the network.

Method 1 - Logging into you router's web interface

The easiest is to login to your router's interface using your web browser.

Raspberry Pi Linux Headless 01

Since every manufacturer’s interface is different, we are using mine shown here as an example, when I click on Network Map > Clients it shows me all devices that are connected to the router (wireless or wired).  We are looking to find raspberry pi as a wired connection shown here in the upper right with an IP address of 192.168.138.64

Your network and router interface will vary (192.168.1.xxx or 192.168.0.xxx), make note of the address you find for the raspberry pi, we'll need it for the next step.

 

Method 2 - Scanning your network from your pc/laptop

In Windows/Mac/or Linux you can download a free program called Angry IP Scanner http://angryip.org/download/

You just input the IP address range that your network is running (typically 192.168.1.1 to 192.168.1.255 or 192.168.0.1 to 192.168.0.255) and hit Start

Raspberry Pi Linux Headless 02

 

You can also scan form the command line in linux using a tool called nmap

Install Nmap

sudo apt-get update  && sudo apt-get install nmap

then scan and find the pi (substitute 192.168.138.* with your network IP range (typically 192.168.1.* or 192.168.0.*)

nmap -v 192.168.138.* | grep "raspberrypi"

Raspberry Pi Linux Headless 03

 

Connect to the raspberry pi remotely

Now we have the IP address, we'll ssh into the raspberry pi, with windows you can download a free program called Putty. http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

For Windows on Intel x86
PuTTY: putty.exe

 

Run the program putty and find Specify the destination you want to connect to and type in the IP address of your raspberry pi, leave everything else default

or from the linux terminal type

ssh pi@<ip-address-of your-pi>

 either method you choose, the first time you connect, you'll be prompted "Are you sure you want to connect, answer Yes

Raspberry Pi Default login credentials are

Login: pi

Password: raspberry

Once connected, you'll have a terminal similar to the one shown here

Raspberry Pi Linux Headless 04

 

Configure the basic setup of the raspberry pi remotely

We need to proceed with a few steps to configure your pi

In the ssh terminal type

sudo raspi-config

You'll see this

Raspberry Pi Linux Headless 05

We are going to proceed with 4 steps navigating the setup menu to make  sure your pi is fully configured, just navigate through the terminal with these steps outlined below

- Step 1: Expand Filesystem

We just need to make sure that we can use the entire SD card installed.  Highlight (up/down arrows) Expand Filesystem and hit enter.  Once complete hit enter to return to the menu above

- Step 2: Change User Password

Highlight Change User Password and hit enter.  You'll be prompted to enter in your new password (so it will no longer be the default: raspberry).  Once complete hit enter to return to the menu above

- Step 3: Enable Boot to Desktop (Optional)

If you do plan on using the pi in the future with an external display, you can choose to highlight and select this option.  Booting to desktop if not needed will just waste resources if you plan on keeping it headless.

- Step 4: Internationalisation Options

You change the time zone here to match your location.  You can change the default keyboard layout and language as well.  I have mine set Time Zone: US/Central, Language: en-us-UTF8

All of the other options are not needed for our typical setup.  You can now arrow across and highlight finish and hit enter to exit the setup menu.  It will prompt you to reboot the pi, select <Yes>.  We're almost done at this point!

 

Final configuration for our pi

Log back into the pi using ssh, we will need to input the new password you choose to login.

- Update the software on your pi

In the ssh console terminal type

sudo apt-get update && sudo apt-get upgrade

 Select Y and hit enter when prompted.  This will download and update all of the software packages that are currently installed.  This may take 5-10 minutes, here's the point you'll need to grab the coffee.

Update the distribution if available

sudo apt-get dist-upgrade

Update firmware if available

sudo rpi-update

 
I always like to reboot after any major updates

sudo reboot

 

- Assign a statc IP to the raspberry pi

Do this so you can always connect to your raspberry pi with the same IP address

First we'll make a copy of the original configuration file, in case something may happen (nothing wrong ever happens so you can skip this step :) )

sudo cp /etc/network/interfaces /etc/network/interfaces.old

Next we edit the network configuration file

sudo nano /etc/network/interfaces

You should have the default /etc/network/interfaces file that will look like this

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet manual

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

 

We will change the above file to this.  Replace the section labelled under eth0 with the static IP information for your network, the new file should look like this

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.42
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
dns-nameservers 8.8.8.8

dns-nameservers 8.8.4.4

auto wlan0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto wlan1
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

 

Here's is a look at the same file above, with only the eth0 section, broken out as an example of what needs to be edited.  Items to edit = Yellow, My comments (do not include in file) = blue

auto eth0
allow-hotplug eth0
iface eth0 inet static

address 192.168.0.42
#change IP "address" in your network that you want the raspberry pi to be on (ie: 192.168.0.200 or 192.168.1.200) keep the first 3 octets the same as your network

network 192.168.0.0
#change "network" to the address of your network, (typically it will be 0 ie: 192.168.0.0 or 192.168.1.0) The first 3 octets will be the same as the IP address

netmask 255.255.255.0
#leave this the same for typical networks

broadcast 192.168.0.255
#"broadcast" is the same 3 octets as your IP and network address, with the last being 255 (ie: 192.168.0.255 or 192.168.1.255)

gateway 192.168.0.1
#change "gateway" this to the IP address of your router (Typical router's end in .1 or .254)

dns-nameservers 8.8.8.8
# add this to allow dns resolution on you static interface (8.8.8.8 is a public DNS server)

dns-nameservers 8.8.4.4
# add this to allow dns resolution on you static interface (8.8.4.4 is a public DNS server)

 

After your are done editing in nano, hit ctrl-x and save the configuration

Reboot the pi for all the changes to take effect

sudo reboot

 

Setup Wifi on your raspberry pi

If you have a USB wifi adapter, you can use my guide where I walk through the steps of setting up the wifi access through the command line

Raspberry Pi multiple WiFi setup through the command line

 

You're done with the basic setup of the raspberry pi, now have some fun!

 

Read 7442 times Last modified on Monday, 22 February 2016 13:39
Algis Salys

Creator and owner of algissalys.com.  Linux enthusiast, electronics tinkerer, and likes to spend time in the workshop building and creating new projects.