The Random Thoughts of a Geek heading for Banbury
The Random Thoughts of a Geek heading for Banbury

Running a Headless R-Pi

The Raspberry Pi is an awesome little computer that can feed either a composite video feed, or a HDMI output, however most of the time I want the thing headless, If you set up Rasbian the same way as I showed in the last guide then this will work for you:

A Video πŸ™‚

Getting Terminal access (SSH)

  1. Turn Internet sharing on, sharing your connection from Wi-Fi, to Ethernet
  2. Plug your R-Pi Ethernet cable first, then power in and wait for a few moments (gives it time to boot).
  3. Open a terminal window and type
    cat /private/var/db/dhcpd_leases

    you will get back information regarding your Pi, including the ip address

  4. type
    ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected]{ip address}
  5. Now you are in the R-Pi you should run the Raspberry Pi configuration tool
    sudo raspi-config
  6. Before doing anything else
    sudo apt-get update
    sudo apt-upgrade

Getting VNC

  1. Type
    sudo apt-get install tightvncserver
  2. Once you’re back at the Bash prompt you need to set up Tight VNC Server, so type

    and give it a password, unfortunately you can’t leave it blank πŸ™ and when you have finished that type

    vncserver :1
  3. Download Chicken (used to be Chicken of the VNC), Open and Run
  4. In the hostname type the ip address of your R-Pi, the display number you want to connect to (in our case 1), and the password from above.

Setting VNC up as a Demon (auto start)

  1. Install netatalk
    sudo apt-get install netatalk
  2. Make a file in /etc/init.d:
    sudo nano /etc/init.d/tightvncserver

    with the following content:

    # Provides: vncboot
    # Required-Start: $remote_fs $syslog
    # Required-Stop: $remote_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start VNC Server at boot time
    # Description: Start VNC Server at boot time.
    # /etc/init.d/tightvncserver
    # Carry out specific functions when asked to by the system
    export USER HOME
    case "$1" incase "$1" in
      su pi -c '/usr/bin/vncserver -geometry 1440x900'
      echo "Starting VNC server"
      pkill vncserver
      echo "VNC Server has been stopped (didn't double check though)"
      echo "Usage: /etc/init.d/tightvncserver {start|stop}"
     exit 1
    exit 0
  3. Make the file executable using
    sudo chmod +x tightvncserver
    sudo update-rc.d tightvncserver defaults
  4. Create the avahi rfb service file
    sudo nano /etc/avahi/services/rfb.service

    and add this content:

    <?xml version="1.0" standalone='no'?>
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
      <name replace-wildcards="yes">%h</name>
  5. To keep LXDE happy:
    cp -rp /etc/xdg/lxpanel/profile/LXDE/* ~/.config/lxpanel/LXDE/

Leave a comment

Your email address will not be published.