Wednesday, 9 October 2013

My first Raspberry Pi - day 2

Reminder: this is not a tutorial on how to set up a Raspberry Pi. I'll be going a long way "off piste" compared to the usual way of doing things. This illustrates how flexible and customisable Linux can be, but when I get into difficulty there's no support to help solve problems.

Memory usage

I was slightly surprised when I first ran the 'free -h' command to see that the Pi has swap enabled by default. Using swap on flash memory (such as an SD card) is a seriously bad idea, given the limited number of write cycles flash memory allows. I can only assume the normal Pi user is likely to run out of physical memory, making swap essential. I'll be adding an external disc drive later, and putting some swap area on that, but until then I've disabled the swap as follows:
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove

Wi-fi connection

My wired computer network only extends as far as my "office" - elsewhere in the house I need wi-fi so I've bought a USB wi-fi dongle to use with the Pi. The dongle was recognised immediately I plugged it in to the USB hub, as shown by the output of 'lsusb'. I found several conflicting guides to setting up wi-fi on a "headless" Pi. I eventually got it working with the following /etc/network/interfaces file:
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid xxxxxxx
wpa-key-mgmt WPA-PSK
wpa-group TKIP CCMP
wpa-psk xxxxxxxxxxxxxxxxx
Lastly I changed the hostname used by the wired interface so I don't have duplicate hosts on my network if both interfaces are connected. This can't be set within /etc/network/interfaces so I had to edit /etc/dhcp/dhclient.conf instead, adding the following lines:
interface "eth0" {
  send host-name = "firefly-hw";
}
It would be nice to get the "firefly" part of the name from gethostname() but I couldn't find a way to do this.

Tuesday, 8 October 2013

My first Raspberry Pi - day 1

I'm a bit late to jump on the bandwagon, but I've finally got round to buying myself a Raspberry Pi bare bones computer. There are many web pages out there with good tutorials on how to set up a Pi. This is not one of them. It's just a brief account of what I've done with mine.

As I plan on attaching lots of USB peripherals (web cam, PVR, weather station, disc drive, wi-fi dongle, ...) I decided to buy a good quality USB hub with a fairly beefy power supply (3A). This is sufficient to power the Pi, so no additional supply is needed. The only disadvantage is that one of the USB ports is occupied just powering the Pi. Also there are two USB cables between hub and Pi - one for data and one for power - which is a bit of a waste.

Initial setup

I regard myself as reasonably proficient with Linux, so I decided to skip the normal "NOOBS" software and jump straight to a "headless" setup of raspbian. I downloaded the image (version "2013-09-25-wheezy") from http://www.raspberrypi.org/downloads and flashed it to a 4GB SDHC card. I put the card in the Pi, connected an Ethernet cable, powered on and within a few tens of seconds an entry for "raspberrypi" appeared in my ADSL modem router's DHCP table.

From a terminal window on my main machine I was able to ssh to pi@raspberrypi and login with the password raspberry. As prompted, I then ran 'sudo raspi-config' and selected the following options:
1 Expand Filesystem (to use all the memory card)
2 Change User Password (for now - I'll enable secure passwordless login later)
4 Internationalisation Options => I2 Change Timezone (set to Europe/London)
8 Advanced Options => A2 Hostname (all my computers are named after machines or characters from Gerry Anderson's "Thunderbirds" - the Pi is now called firefly)
8 Advanced Options => A3 Memory Split (set minimum GPU memory - I don't expect to use the GPU at all)

Passwordless login

There are many tutorials on the web about setting up passwordless login with ssh. As I already have this set up on my other machines I simply had to copy my key to the Pi by running 'ssh-copy-id -i ~/.ssh/id_dsa.pub pi@firefly' on my main computer. Now I could ssh to pi@firefly without a password.

Copying the key to the 'root' account enables passwordless login as root as well:
sudo mkdir /root/.ssh
sudo chmod go-rx /root/.ssh
sudo cp ~/.ssh/authorized_keys /root/.ssh/
Finally we can disable password login. On the Pi, edit the ssh configuration file ('sudo vi /etc/ssh/sshd_config') and change the line '#PasswordAuthentication yes' to 'PasswordAuthentication no', then restart the ssh daemon: 'sudo /etc/init.d/ssh restart'. Test by trying to ssh to a non-existent account: 'ssh fred@firefly' now gets the response 'Permission denied (publickey)'.

This is a bit more security than most people need, but I intend to allow ssh connections to my Pi from the Internet (so I can check up on things when away from home) so it's vital to frustrate the thousands of repeated attempts to login as root that any exposed machine will receive.

Wednesday, 1 May 2013

If a world famous search engine wanted some good publicity...

...they could help owners of copyright in images track down their "orphaned" works.

A hot news story in the UK in recent days has been the passing of a law to allow photographs to be published without the copyright owner's consent, provided a "diligent search" has been undertaken to find the owner. See http://www.bbc.co.uk/news/technology-22337406

Many photographers are careful to embed "metadata" within their photographs that explicitly declares the ownership of the image, but many online publishers (e.g. Facebook and the BBC) strip all such metadata from the "user generated content" they publish. This is probably excusable, since it's the only practical way to avoid the risk of obscene or libellous material being secreted in the metadata. By the way, if you're looking for an easy to use program to add metadata to your own photographs, I recommend Photini (what I wrote).

Apparently the new law makes it the photographer's responsibility to discover re-publication of his or her images and then to apply for payment from a central fund. The only problem is, how do you find out if one of your images has been re-published? I recently did a Google image search for my name, and found two instances of photographs I'd uploaded to Flickr being used without my permission. In one case the image was credited to me, in the other they'd included my name in their image file name. (In both cases, had they asked, I'd have said yes.)

With Google's huge database of Internet published images, and a bit of image processing software, they could make it much easier to find instances of an image being re-published elsewhere on the web where the perpetrator hasn't made it quite so easy to spot the theft. They already detect web pages with similar text, to reduce their pagerank on the assumption it's copied boilerplate text, so why not find very similar images in the same way? This would also help those performing a "diligent search" to find the true author of an image, rather than simply allowing them to assume it's an "orphan work".