S6 Install a personal FTP server for file sharing

Setting up Ubuntu's file sharing component, as described in Tip 28, on page 84, is perhaps the best method of making files available to others across a network. However, the underlying technology—known as SMB/CIFS—is not very reliable. Network shares sometimes mysteriously disappear, only to reappear minutes later. Sometimes a computer stubbornly refuses to connect, even though everything is set correctly. Often there are long pauses.

A more robust method of sharing files on your Ubuntu machine is to install a personal FTP server. This is less secure than SMB/CIFS33 but if you're working on a private network protected by a NAT and/or firewall device then it should be fine (most broadband routers use NAT). Every operating system available right now (Windows XP/Vista, Mac OS X, and other versions of Linux) can natively connect via FTP, without installing additional software.

Here are the necessary steps to install and configure a personal FTP server—these steps also activate anonymous access, so no username or password is required:

1. Start by installing vsftpd using Synaptic.

2. During installation, vsftpd creates a new dummy user account— ftp—where the shared files will be stored. However, before any file sharing can happen, a container folder must be created within the dummy account's /home folder. To do this, open a command-prompt and type the following:

33. FTP servers send everything—including usernames and password details— unencrypted across the network. Thus, passwords could theoretically be "sniffed" by malign interests. Ideally we would create an SFTP server for the tip above but, unfortunately, Windows XP/Vista does not natively support SFTP.


File Edit View Search Tools documents Help

New Open Save Print,.. Undo Find Replace

i +vsftpd.conf £3 j

# Run standalone? vsftpd can run either from an inetd or as a standalone

# daemon started from an mitscript.


# Fiun standalone with IPv6?

# Like the listen parameter, except vsftpd will listen on an IPv6 socket

# instead of an IPv4 one. This parameter and the listen parameter are mutually

# exclusive. #listen_ipv6=YES

# Allow anonymous FTP? (Beware - allowed by default if you comment this out). anonymous_enable=YES

# Uncomment this to allow local users to log in. #local_enable=YES

# Uncomment this to enable any form of FTP write command.


# Default umask for local users is 077. You may wish to change this to 022,

# if your users expect that (022 is used by most other ftpd's) #local_umask=022

# Uncomment this to allow the anonymous FTP user to upload files. This only

# has an effect if the above global write enable is activated. Also, you will

# obviously need to create a directory writable by the FTP user.

anon upload enabie=YESj'

# Uncomment this if you want the anonymous FTP user to be able to create

# new directories.

anon mkdir write enable=YES

# Activate directory messages - messages given to remote users when they

# go into a certain directory.

di rmessage_enable=YES


Ln 38, Col 23


Figure 3.37: Configuring vsftpd (see Tip 226, on the previous page)

$ sudo mkdir /home/ftp/Shared\ files $ sudo chmod a+rwx /home/ftp/Shared\ files

3. Open vsftpd's config file in Gedit: gksu gedit /etc/vsftpd.conf. Look for the the following lines in the file and remove the hash (#) before them (see Figure 3.37 for an example of the edited file with the relevant lines highlighted):

wri te_enable=YES anon_upload_enable=YES anon_mkdi r_wri te_enable=YES

4. Following this, save the file, close Gedit, and type sudo /etc/init.d/vsftpd restart to restart the vsftpd with the new settings. It will automatically start each time the computer boots.

To access the new shared folder on your computer, click Places ^ Con-

nect to Server, and in the Server field, type localhost. Then click the Connect button. Following this you can create a Nautilus bookmark for future access—click Bookmarks ^ Add Bookmarks in a Nautilus window, or hit [Ctrl ]+[d].

To access the shared folder from other computers, you'll need to tell the users of the computers the IP address of your Ubuntu computer. To discover this, right-click the NetworkManager icon and select Connection Information. Then look for the IP Address line in the dialog box that appears. You will see four numbers separated by periods. On my test computer, I saw

• Windows: Open a My Computer window and, in the Address bar, type ftp://address, replacing address with what you discovered earlier. Then right-click and drag the Shared files folder to the desktop and, when you let go of the mouse button, select Create Shortcut Here. From now on, the desktop shortcut can be used to access the shared folder contents, even after a reboot.

• Macintosh OS X: By default, Macs can only access an anonymous FTP in read-only mode. To do this, open Finder and then click Go ^ Connect to server. In the Server Address text field, type ftp://address, replacing address with what you discovered earlier. A Finder window will open showing the contents, but this can be closed. A desktop icon will also appear for the new FTP connection. Right-click it and select Make alias. Use this new desktop shortcut whenever you wish to connect in future.

To get read/write access to your new FTP server, Mac users will need to install MacFusion. Head over to http://www.sccs.swarthmore. edu/users/08/mgorbach/MacFusionWeb/, then download and install MacFuse and MacFusion. Launch MacFusion after installation and click its icon at the top right of the screen. Then select Quick Mount and then FTP. In the dialog box that appears, type an easily remembered name into the Name field (something like Ubuntu shared will do), and the IP address you discovered earlier into the Server field. Then click OK. From now on, click the relevant entry after clicking the MacFusion icon.

• Other Ubuntu computers: Right-click the desktop and select Create Launcher. In the Name text field, type something memorable— anything will do (maybe "Shared folder on Bob's computer"). In the Command field, type nautilus ftp://address, replacing address with the

Shutdown, reboot, hibernate, or sleep Ubuntu with a single click M 268

address you discovered earlier. Then click OK. Use this shortcut in future whenever you wish to connect. Alternatively, if you don't wish to have a desktop shortcut, you can connect once and then create a Nautilus bookmark. Then delete the shortcut.

You might also want to look at Tip 131, on page 173, which describes the cornucopia of FTP tools provided under Ubuntu.

Was this article helpful?

0 0

Post a comment