My Raspberry Pi arrived. Here's how I started using it.

Posts Tagged: setup

SSH

Text

Something I had overlooked in my previous entries was the lack of any guide to SSH (Secure Shell). This basically enables you to access a computer (including, of course, your Raspberry Pi) using a command line interface on another computer connected via a network - so like running the Terminal application directly on your Pi, but on another computer. This is very useful if you’re running your machine without a screen but need administer it without using VNC.

If you’ve installed Raspbian (and if you’re a beginner like me, I highly recommend you do) you’re given the option to switch this on the first boot up. If you didn’t, you can start the SSH service by entering the following into the Terminal, the reboot your machine:

sudo mv /boot/boot_enable_ssh.rc /boot/boot.rc
reboot 

With the SSH service now running, you need the Raspberry Pi’s IP address to connect. Enter “ip addr show” and your IP address should be on the last line after the word “inet” (see here for more details).

Next you need to connect to your Raspberry Pi using an SSH client. 

  • Unix/Linux users: I’m surprised you’re reading this guide, you probably know what to do. :-)
  • Mac users: Terminal is in your Utilities folder, in Finder select Go from the menu bar, locate it in Launch Pad or just use Spotlight.
  • Windows users: A quick Google search revealed a free SSH client called PuTTY. You are probably done here, I’m not familiar with Windows clients but will try and update this post within a couple of days with more info for Windows users.

With your client open and ready to go, connect to your Raspberry Pi. The following assumes you’re using the default username “pi”. Enter:

ssh pi@xxx.xxx.xxx.xxx (where xxx.xxx.xxx.xxx is your Raspberry Pi’s IP address)
Then enter your password - the default is “raspberry”. 

You should now see a different prompt, “pi@raspbmc:~$”, and you’re ready to enter commands. Type “ls” to list the files in the current directory. Type in any other commands you would in a regular Terminal window, such as in any of the guides on this Tumblr. When you’re done, just type “exit” and you’ll return to the normal prompt, such as “compname:~ username$

Notes:

  • On Raspbmc I found I had to go through an initial configuration the first time I connected - choosing locale, etc - which is all possible using the SSH session.
  • I created this post in preparation for a lengthy one on Raspbmc which will require some SSH-ing.  I hope to publish the article within the next week.

Text

If you’re planning on using your Raspberry Pi as an appliance, you’ll want it to automatically login and load LXDE (the GUI). You may also want to do this if you are just tinkering around with the Raspberry Pi (as I am at the moment) and are using it without a monitor using a VNC server. 

This eLinux Wiki guide explains how to do it, but if you want to start your VNC server instead, instead of adding startx to the bottom of the /etc/profile file, add the command you use to start your VNC server, e.g. “vncserver :1 -geometry 1024x728 -depth 24”.

EDIT: eLinix Wiki updated their entry, the above will no longer work. This is a better way.

Text

Another post for Mac users. If you’ve followed my previous post to setup Avahi for AFP auto discovery, you might want to do the same for VNC.

To do this, add a new service under /etc/avahi/services. Using Terminal:

  1. Run “sudo nano /etc/avahi/services/rfb.service
  2. Enter the following:
    <?xml version="1.0" standalone='no'?>
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <service-group>
      <name replace-wildcards="yes">%h</name>
      <service>
        <type>_rfb._tcp</type>
        <port>5901</port>
      </service>
    </service-group>
  3. Under the <port> element in step three, ensure you enter the correct port number that you chose when starting your VNC server .
  4. Press ctrl and x to exit, then y to save and press return after confirming the file location
  5. If your Mac doesn’t pick it up within a view minutes, restart the avahi service: “sudo /etc/init.d/avahi.deamon restart

You should now see a “Share Screen…” button when you select your Raspberry Pi in the Finder side bar. Click this and the Screen Sharing app will open, enter your VNC password (leave the username blank). Other VNC software should be able to discover it also, though I’ve only tested it on Mocha VNC for iPad.

Strangely, the Apple Remote Desktop app still does not discover my VNC server using bonjour. I’ll update this post if I find out why.

Source: fusionsecurity.blogspot.co.uk

Text

This post will only interest you if you’re using a Mac. AFP (Apple Filing Protocol) is the protocol Macs use to share files over a network. This post will guide you through setting this up using Netatalk. It will also cover setting it up to be easily accessible without the IP address.

To install Netatalk, simply use apt-get:

  • sudo apt-get install netatalk

You should now be able to access your Raspberry Pi from the Finder side bar and under Network (shift + command + k).

Finder sidebar - Shared

EDIT: The remainder of this post is now outdated and should not be required once you have installed netatalk.

This installs 2.1.2 of Netatalk which is not the latest (2.2.3 at time of writing) which may cause issues with using this for Time Machine and with Lion, although I have not experienced any issues on my two Lion machines. My attempts at installing 2.2.3 failed though I’m sure it’s possible.

When apt-get has finished, you can connect from the Mac:

  1. In Finder, open the Go menu and select “Connect to Server…” (⌘K).
  2. Enter “afp://” followed by your Raspberry Pi’s IP address.
  3. Enter your Raspberry Pi’s username and password (default username is “pi” with password “raspberry”).
Connect to server dialog
Now wouldn’t it be nice if the Mac showed your Pi under the shared section of the Finder sidebar? For this the Raspberry Pi needs to be advertising itself on the network, Apple’s Zero Configuration protocol for this is called Bonjour. This is supported under Netatalk 2.2.3 but not in the version we’ve installed. Avahi can do this for us, but requires a bit more work (below steps have be adapted from this article by Sam Davis):
  1. First run “sudo apt-get install avahi-daemon”.
  2. Next, make sure it runs at startup, enter “sudo update-rc.d avahi-daemon defaults”.
  3. Create a configuration file containing information about the server. Run “sudo nano /etc/avahi/services/afpd.service”. Enter (or copy/paste) the following:
    <?xml version="1.0" standalone='no'?><!--*-nxml-*-->
    <!DOCTYPE service-group SYSTEM "avahi-service.dtd">
    <service-group>
       <name replace-wildcards="yes">%h</name>
       <service>
          <type>_afpovertcp._tcp</type>
          <port>548</port>
       </service>
    </service-group>

    Press ctrl and x to exit, then press y to to save changes and return after confirming the location.
  4. Restart Avahi: “sudo /etc/init.d/avahi-daemon restart

Text

Once you’ve copied the Linux image to your SD card, be sure to resize the partitions to ensure all the SD card’s space is available (or you can create an additional partition). Follow this eLinux Wiki guide, which explains how to do it from Linux and from the Raspberry Pi itself. If, like me, you’re not running Linux on your main machine, follow the the steps in section 5.2.

Text

So you’ve got your Raspberry Pi setup, but what if you don’t have a dedicated monitor to use with it (for example, mine’s connected to my TV). How can you use it without disrupting your setup? VNC (Virtual Network Computing) allows you to see your Pi’s desktop and control it remotely using another computer running Mac OS X, Windows or Linux (and other devices too).

The VNC server software runs on your RPi, access it by running VNC client software on your other device.

The VNC Server

There are various guides for this online, most suggest using the TightVNC server software, here’s my summarised need to know version, run all commands from the command line:

  1. Install tight VNC: “sudo apt-get install tightvncserver”
  2. Run the program: “tightvncserver”
  3. Start a VNC session: “vncserver :1 -geometry 1024x728 -depth 24”

Notes:

  • Configure the session’s resolution after the -geometry argument. In the above 1024x768 is used. The RPi is capable of full HD so you could try 1920x1080.
  • Colour depth is specified by the -depth argument. In the above exampe, 24-bit colour depth is used. You could use 16-bit instead to reduce network traffic.
  • You can start more than one VNC session by running subsequent vncserver commands, just increment the first digit: e.g “vncserver :2 …” for a second, ”vncserver :3 …” for a third (I don’t know how many the RPi could handle).
  • You can set this to run at start up, see the eLinux wiki tutorial, or look for a later post on this blog on automatic login which can start the VNC session with less effort.

The VNC Viewer/Client

There are lots of VNC clients you can use, depending on your platform. I’m using Apple’s Remote Desktop software which is incredibly powerful (especially when administering Macs) but is overkill if you are just using it with your RPi. TightVNC has a free client application, there’s a native Windows version and a surprisingly good (but limited) Java version, which should run on any desktop/laptop system. A Google search should find you a suitable app for your own system.

To connect to your RPi:

  1. Get your RPi’s IP address by running “ip addr show”. The IP address with be shown as highlighted in the image below.
  2. Connect your client to the IP address obtained from 1. 
  3. Use port “590x”, where “x” is the session number used in step 3 in the previous section. If this doesn’t work, enter the IP address followed by “:x”, e.g. “192.168.1.50:1”.

ip addr show command example

Text

If you’re using the Debian “squeeze” flavour of Linux you may have seen the “Enter administrative password” dialog box pictured below and stumbled when trying to authenticate as the admin user.

Authentication dialog

The reason, if you’re using the standard “pi” user account, is that you’re not an admin user and you don’t have the password for the superuser/root account. This is not an issue if you’re at the command line, using “sudo” before your command executes it as the superuser. Not so in “X” (the GUI environment), there are two solutions I have seen on the Raspberry Pi forums:

  • Option 1: Reset the root password. At the command line, enter the command below and enter the new password (credit: spurious).

…to set the root password you could write:

“sudo passwd root”

  • Option 2: Correct the bug/configuration issue that causes the problem in the first place (credit: croston). 

A bug in the RPi Debian distribution - applications in X still ask for the root password, not the sudo password. You can fix this with the following command:

“gconftool-2 --type bool --set /apps/gksu/sudo-mode true”

Source: raspberrypi.org