Raspberry Pi Headless


Headless is a term used to describe a machine that does not have a screen.
This article is how you setup your Pi to be used without a computer screen attached (as my HDMI to VGA cable didn’t work for me) and using my normal windows PC which is connected to the internet.

Firstly you need to log into your Pi.
If you can attach a screen temporarily to help you get setup I recommend that you do that as this will make life allot easier and skip Step 1.
I’m going to run through how to do this without a screen at all as I had to.

So you have already made the OS image on your SD card with the latest stable version from the Pi Download center.
You place that SD card on your Pi and connect an ethernet cable that is connected to your internets router.
You can now plugin the power cable to your Pi switching it on and booting up the OS.

Step 1 – SSH into your Pi
After waiting a few minutes for the Pi to boot up you can go into your router control panel (i.e. virgin media has 192.168.0.1, other providers may have different addresses) and see who is connected to this router.
You should see raspberry-pi connected to the network on this list and it will display and IP address.
My IP shown is 192.168.0.7 but yours will likely be different.
Take note of this IP address as we are now going to SSH into your Pi with IP.
Now on your Windows PC you need to download Putty which is an SSH client (ignore putty if your using MAC or Linux as you can SSH via the terminal)
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html putty.exe is the file you need.
Enter in the IP address of the Pi that was shown on the router     Once you click open it should as your for your Login. If you get a blank screen or you could not connect it could be to:

  • Pi not botted up yet, wait a minute or two.
  • You entered in the wrong IP address (check the IP address on your router contol panel)
  • Your PC is not on the same network as the Pi (make sure the PC is using the same router)
  • Your version of the OS has disable SSH access (Either find a different OS version or google how to enable SSH on your SD card OS files)

So now you should get a response like this after entering in your login details (My OS defult is Login pi Password raspberry):     Ignore the Notice displayed on my example. This is just asking me to run configuration to extend my partition on the SD card. If you get the same notice you can run it now but running it later once your setup is complete is fine too.   Now you need to update your Pi to the latest version so type in the following commands to do that if not already done so (doing this now will reduce issues of old verisons of drivers etc)   sudo aptitude update sudo aptitude dist-upgrade sudo apt-get update sudo apt-get dist-upgrade   You can now SSH into your Pi which technically means you are headless but you have to check your IP address hasn’t changed everytime that you want to login. You cant run startx via SSH but you can use other software as described in Step 3 A nicer method is to connect either a crossover cable or ethernet cable from your Pi directly to you PC. If you wish to try this, continue to Step 2

Step 2 – Ethernet from Pi to PC

WARNING: You are likely to want an internet connection to your Pi after doing this setup which can be done in 2 ways.

1. Share the internet connection on your PC with your Pi. Some routers do not let you do this either due to the setup in the control panel or they reserve the IP 192.168.0.1
By default windows shares the internet connection on 192.168.0.1 which will cause an IP conflict so to test if this will work or not, do the following

  • Connect your Pi (switched on) to your PC via an ethernet cable
  • Control Panel > Network connections > Right click the network cable you used > Properties
  • Click on the advanced tab
  • Check ‘Allow other network users to connect through this computers internet connection’
  • Click Ok

If your internet connection breaks, or you get an error saying ‘Conflict IP address’ then this will not work for you without allot of messing around with the routers setup and your PC. Make sure you uncheck the share option after to put your PC back to the correct settings if you receive this issue

2. Connect to the internet via WiFi on your Pi. There are many different tutorials online about how to do this with different WiFi devices so google examples or look through this example http://www.penguintutor.com/blog/viewblog.php?blog=6281

Now to setup a direct ethernet (or crossover) cable from your Pi to your PC we need to setup static IP addresses between each other.
It has to be part of 192.168.xxx.xxx and not be already used by another network.
So for this example I am using 192.168.250.x (but you can change 250 from anything from 1 to 254, not 0 or 255)
Still logged in via SSH through your router (or directly with a screen attached) you edit interfaces
sudo nano /etc/network/interfaces
then you need to add the following (without disabling your WiFi setup if you have one)
auto eth0 iface eth0 inet static address 192.168.250.2 netmask 255.255.255.0
Save the updates by pressing Ctrl – x then enter

Now you need to setup your PC to work in a similar way
Go to Control Panel > Network connections > Right click the network cable you used > Properties Scroll down the list and click on ‘Internet Protocol (TCP/IP)’ and click properties
Check ‘Use the following IP address’ IP address as 192.168.250.1 Subnet Mask as 255.255.255.0
Click OK and OK again on the previous window
Now you can connect an ethernet cable from the Pi to the PC (might need to restart the Pi) and try and SSH into the Pi with the IP address 192.168.250.2
You should now recieve the login screen which means you are successful. #win
You can connect from the Pi to your PC with the IP address 192.168.250.1 too.
You can make the login process easier by adding named values to this IP address by editing your hosts file in C:\Windows\system 32\drivers\etc\hosts
and adding the line
192.168.250.2 pi-wired
which will allow you to just type in pi-wired when SSH to your Pi.

Step 3 – startx when headless
SSH will only allow you command line access, but if you want to use the GUI on the OS you can use one of the free packages available.
I use tightVNC viewer as it works well for me.
A good tutorial about setting this up is available here: http://www.penguintutor.com/linux/tightvnc

And there we have it.

A headless Pi.

14 comments for “Raspberry Pi Headless

  1. November 24, 2012 at 5:05 pm

    Hi Rob,

    Is there any way to connect the the Raspberry Pi directly to PC? This would be very useful if I don’t have internet access at the moment.

  2. GlynRob
    December 13, 2012 at 12:57 pm

    The easiest way is to just connect the PI to your monitor (HDMI cable required).
    I have only been able to connect to a PC via a router (the example above) so does not require the router to work on the internet.

    Not sure if it is possible to just use an ethernet cable from Pi to PC and be able to login. Worth a google but I haven’t seen it done before.

  3. Stephen
    December 20, 2012 at 7:09 am

    Yes you can connect directly from your R-pi to your PC through ethernet. HOWEVER, it requires a special cable called a crossover cable; so named because it flips the pin configuration from one end to the other for direct device to device connections.

  4. Daniel
    February 4, 2013 at 9:26 pm

    Crossover cables haven’t been necessarily for quite awhile, both the nic on your laptop and the nic on the pi have the ability to switch the pins so that you don’t need the cable.

  5. Jack
    February 25, 2013 at 1:39 am

    Man, this helped so much with me setting up my Pi with my laptop, I couldn’t have done it without this amazing tutorial! Thanks!

  6. March 13, 2013 at 1:52 pm

    Cheers man, this helped a lot.

  7. johnJ
    May 5, 2013 at 7:46 pm

    Thanks – this tutorial helped! Was able to get the tightvnc client work and connect to the server on the pi. Had a lot of problems initially – the hdmi nor the composite port would display anything -finally decided to go headless and this worked.

  8. david echlinn
    May 28, 2013 at 2:28 pm

    Great help, I’m connecting with just an Ethernet cable. I’ve fixed the raspberry to fixed up address. I can ssh off my Mac but only after I have manually logged.

  9. jmf
    August 15, 2013 at 9:40 pm

    ¿ If you don`t know the IP address of the Raspberry? only with ther crossover cable and putty.

    ¿ Can you check the address until you find de RSPI? How?

    Thank you,

    JMF

  10. GlynRob
    August 21, 2013 at 1:57 pm

    Getting the IP address of the PI
    In linux you can use the command
    /sbin/ifconfig
    if you can attach a screen for a few minutes to see the response.

    The other way is to log in to your router manager where it lists all the IPs on the network.

    If you don’t have a screen or access to your router manager then you will need to set the static IP when you do have access to a screen available and run
    sudo nano /etc/network/interfaces
    then add an internal IP to use at home.

  11. drBorrow
    August 25, 2013 at 10:05 pm

    Thanks for a great posting! I have never used a raspberry Pi before but I simply followed everything you said and et voila, it worked like a charm. Thank you so much!

    One question:
    Whilst viewing the Pi device from my laptop (headless and over WiFi), I notice that if I plug a USB keyboard directly into the Pi, it doesn’t seem to register. For example, if I VPN into the Pi from my laptop and open a notepad, it works fine and I can type away. However, if I then try to type into the notepad using the USB keyboard, nothing happens. I cannot seem to type from the USB keyboard connected directly to the Pi. I would’ve thought that the Pi would accept text from either the laptop over WiFi or the USB keyboard.

    Do I need to do a specific setup to accept the USB keyboard?

    Many thanks again

  12. GlynRob
    August 26, 2013 at 2:25 pm

    Hi drBorrow

    When you VPN to your PI you are still using the original computer drivers that reads the input from your keyboard so it works.
    When using a wireless USB keyboard on a linux distribution on the PI it is likely that you have not got the drivers required to read the input from the keyboard.
    If you use a wired keyboard it is likely to work straight away on the PI as any drivers you need are already installed on the linux distribution you downloaded.
    To get your wireless keyboard to work you will need to google for the installation instructions for the type of keyboard you have and the the linux distribution you used.
    i.e. microsoft wireless keyboard on wheezy

  13. William
    October 11, 2013 at 11:47 am

    Also, if you plug a keyboard into your Pi, this is standard input, which you will be able to see on standard output (the HDMI output in this case). But with a keyboard and monitor, you’re no longer headless.

  14. Brian
    February 11, 2014 at 6:16 am

    I was hoping to replace the cable between my pi and laptop with the wireless dongle and run putty on my laptop to access the pi….no router….just the laptop and pi…..any clues???

Leave a Reply

Your email address will not be published. Required fields are marked *