Monday, July 17, 2006

Ridiculously easy home networking with FTP and Zeroconf

This tutorial will cover setting up ridiculously easy, reliable, cross platform, standards based home networking. You will be able to share files from any Ubuntu/Debian system and connect to them from any Linux, Windows or OS X box. If you want to share your files on a firewalled home network but dont want to bother with Samba, NFS, or AFP this is for you.

I chose FTP because it is supported on all systems since the beginning of time, its secure enough for home use and its easy to get working. Samba/SMB is too difficult to set up for the novice user, is Windows centric and has various problems with transfer failures and slowdowns. NFS was designed for Linux, but is, like Samba, too difficult for the novice user.

I started out to do this with SSH, but decided on FTP after seeing GShare. I chose not to use GShare for several reasons: it has a great many dependencies that this approach doesnt require, its FTP server was written from scratch and is therefore almost by definition more insecure and less interoperable than the FTP daemon we will use, and I wanted to lock users into their home directories by default.

Enough with the formalities, lets get to it.

Setting up the FTP daemon

We will use vsftpd (Very Secure FTP Daemon) as our FTP server.

Install vsftpd
sudo apt-get install vsftpd
Configuring vsftpd

We need to modify some vsftpd settings. If you dont feel like editing by hand, just copy mine:
sudo mv -f vsftpd.conf /etc/vsftpd.conf
If youd like to edit your configuration file by hand, open the configuration file with
sudo gedit /etc/vsftpd.conf
Change or uncomment (remove the #) the following parameters
Start vsftpd
sudo /etc/init.d/vsftpd restart
Vsftpd will now always start automatically when your computer starts.

Setting up Zeroconf networking

Vsftpd will do the file transfer for us, but need some way to find services and name the boxes on our network. Avahi allows us to give our systems names without setting up a DNS server and easily discover services. It is a completely free Zeroconf daemon and the choice of Gnome.

Install Avahi
sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns service-discovery-applet mdns-scan
If all you want is convenient host naming that allows you to use DNS names (ie. hostname.local) without setting up your own DNS server, you can skip the next section. Instructions are provided for connecting to shared files with and without zeroconf service announcements.

Create Zeroconf Service Announcements (Optional)

Most OSes zeroconf service discovery support, even zeroconf creator's OS X, is very limited. The potential of this technology is great, but for now this section is helpful but not critical.

Like before, you can just copy mine
sudo mv --force --target-directory=/etc/avahi/services/ ftp.service
Or if you like to edit by hand, run
sudo gedit /etc/avahi/services/ftp.service
and paste
<?xml version="1.0" standalone='no'?>
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<name>FTP file sharing</name>
Save an close Gedit.

Restart Avahi
sudo /etc/init.d/avahi-daemon restart

Now do what you just did on every Ubuntu/Debian computer you wish to share files from. You only need to do the Install Avahi section on the Ubuntu/Debian systems that you want only to connect to shares from.

Connecting to your shared files

Connect from Ubuntu/Debian (or any Gnome desktop)

With zeroconf service announcements

Click Places->Network Servers. You should see an icon labeled FTP File Sharing. Right click on it and click Connect To This Server. You can give this link a new name or just click Connect.

You should now see an icon labeled FTP File Sharing on your desktop. Double click the icon. You will be asked for your username and password: Select Connect as User. Enter your username and password *that you use to log into the box you are connecting to*. Check 'Remember password for this session.' After you click OK, your home directory on your remote machine should appear. You should not have to enter your username or password again until you log out of your computer.

Without zeroconf service announcements

Click Places->Connect to Server. Click the Service Type dropdown and select 'FTP (with login)'. Enter hostname.local in Server, in 'User Name' enter the username *that you use to log into the box you are connecting to*, and set 'Name to use for this connection' to FTP File Sharing.

You should now see an icon labeled FTP File Sharing on your desktop. Double click the icon. Enter your password *that you use to log into the box you are connecting to* and check 'Remember password for this session'. After you click Connect, your home directory on your remote machine should appear. You should not have to enter your username or password again until you log out of your computer.

Connect from OS X

OS X natively supports connecting to FTP through the Finder. The only drawback is that mounted shares are read only.

Without zeroconf service announcements

Open Finder. Click Go > Connect to Server. Enter 'ftp://hostname.local' then click Connect. Enter your username, password and check 'Remember this password', then click OK. There will now be a new Finder entry for your ftp site.

With zeroconf service announcements

Open Safari. Press Option+Apple+B to open bookmarks. Click on the Bonjour icon. Find the name of the service you want to connect to and double click it.

Connect from Windows

Because Microsoft is backing its own zeroconf-ish protocol, Windows support for zeroconf service announcements is practically non-existant. Apple's Bonjour client is the only real free support for zeroconf on Windows. Its service browsing functions are extremely limited, but it works quite well for host naming. Because service discovery support is so limited, we will not use service discovery when connecting from Windows. Therefore, after installing Bonjour, you can use can use either of the following connection methods whether or not you created zeroconf service announcements.

Install Bonjour

[url=]Download Apple's Bonjour for Windows here[/url]. Run the setup like any other; answer Next, Yes and OK to every question. After your computer restarts, you will have full zeroconf naming support.

With Explorer

This method does not create a new drive letter; you will only be able to access files through Explorer.

Open an Explorer window. Click Tools > Map Network Drive... Click the "Sign up for online storage or connect to a network server" hyperlink. Click Next on the Add Network Place wizard. Click the "Choose another network location" icon and click Next. Enter the host to connect to in the form ftp://hostname.local and click Next. Uncheck "Login anonymously" and fill in the username that you want to connect with then click Next. Change the name of the network place if you wish and click Next then click Finish.

A window should open and you should be prompted for your password. Enter your password and check Save Password then click Log On. You should now see your files on the remote machine.

With NetDrive

Windows cannot mount FTP as a drive natively, but there is a program called NetDrive that does an excellent job. There is already a tutorial that is more complete than anything I could do so [url=]follow these instructions to install NetDrive[/url] and make one critical change: When you get to "add new site", enter the "Site Address/URL" in the form HOSTNAME.local, where HOSTNAME is the name of the box you are connecting to.


Thats about all there is to it.

The major drawback to this setup is that most gui-less Linux applications will not be able to save and open files directly. Applications designed especially for Gnome will most likely work, but support is currently hit-and-miss. If you find that your application cannot directly access the share, you will need to manually copy the files, work on them, then copy them back.


IMHO, this completely blows away Samba/SMB and NFS for ease of setup, ease of use and cross platform interoperability. Making our shared files act like part of our file system, and therefore work with any application, is possible and will be covered in a future update.


Mount FTP with as a drive with FUSE.
Instructions for KDE desktop.
Remove sections on zeroconf service announcement as it is of limited use?

Edit 2006/08/26: Made zeroconf service announcements optional. Added mounting instructions for OS X and Windows.

Sunday, May 21, 2006

2000 Military Spending Cartogram v1

This is a cartogram that shows relative global military spending for the year 2000. Without getting too demagogic, I think its rather appropriate that this map is basically how most Americans think the globe looks anyway.

The main problem with this map is that the United States's spending is so far beyond any other single nation's, with the exceptions of China, Russia and Japan, that they appear nearly white. Two separate gradients may be necessary to get a better reflection of the finer gradations in spending.

It was created using (almost) all free software. Im putting together a tutorial on making cartograms using strictly free tools, but in the mean time here is a list of tools I used.

Correlates of War
Blue Marble Geographics World Countries Map

Microsoft Access 97
Frank Hardisty's Cartogram Generator
Quantum GIS