Set up Dropbox on a GUI-less Linux server

Vincent Danen simplifies the steps to setting up Dropbox to work even with a GUI-less Linux computer. Dropbox allows you to synchronize files across multiple machines.

Dropbox is a great way to synchronize files across multiple machines. A free basic Dropbox account gives you 2GB of storage, while pro paid accounts give you 50GB or 100GB of storage space. Dropbox works great on desktops; there are clients for Linux, Windows, and OS X. There are GUI tools provided to manage the Dropbox and set it up for these operating systems. But what happens if you want to link a Linux computer that doesn't have a GUI? It is possible, with a bit of work, to make Dropbox run without a GUI, allowing you to synchronize files with servers that are running headless or where a user account may not be logged in all the time.

The Dropbox wiki has a page that describes how to do this, but it contains a lot of information, some of which is obsolete or contradictory. This tip takes all the relevant information for the setup to make it quick and easy to get up and running within minutes.

To begin:

# mkdir -p /tmp/dropbox
# cd /tmp/dropbox
# curl -OL
# curl -OL
# curl -L -o dropbox.tar.gz

Use plat=lnx.x86 if you want the 32-bit client. This creates a temporary directory for our Dropbox install files, and downloads two necessary python scripts: which creates fake stub copies of GUI libraries so the dropboxd daemon starts, and which displays dropbox configuration information.

Decide which user will be running the Dropbox client; this could be a dedicated user or it could be a regular user. You can also have more than one Dropbox instance running on the system, so you may opt to set it up for multiple users (although each user can only run one Dropbox instance). For this example, we will have created a special user "dropbox" which will run this Dropbox client.

# su - dropbox
$ cd ~/
$ tar xvzf /tmp/dropbox/dropbox.tar.gz
$ cd .dropbox-dist
$ python /tmp/dropbox/
dropboxd ran for 15 seconds without quitting - success?

The script requires gcc, so you must have gcc installed on the system. This creates fake stub copies of the GUI libraries so that dropboxd will start. At the end, you can see that it launched dropboxd; press [CTRL]C to exit the script. dropboxd should still be running in the background:

$ ps ax | grep dropboxd
24001 pts/0    S      0:00 sh -c { /home/dropbox/.dropbox-dist/dropboxd; } 2>&1

Now that dropbox is running, we need to link it to an existing account:

$ cd ~/
$ python /tmp/dropbox/
host_id = 0bd9c5a15458fbc31f85e892faa7dac4
schema_version = 6

Grab the host_id from above. Login to the Dropbox web interface, and once you have logged in, manually visit this URL:[HOST_ID]

Replace [HOST_ID] with the host_id that outputs. When you have done that, the Dropbox site will tell you that you have successfully linked a new computer. Go to your Account settings and then My Computers and you will see the new computer listed.

If you have not killed the dropboxd process that started, you will find that it is already downloading the files from the Dropbox to ~/Dropbox/ in the background.

To start the dropboxd daemon in the background at boot, you can add the following to your /etc/rc.d/rc.local init script:

daemon --user dropbox /bin/sh -c "/home/dropbox/.dropbox-dist/dropboxd&"

This will start dropboxd in the background with the privileges of the user for which it is installed (in this case, the user is "dropbox"). If you want to do a system-wide initscript, visit the Dropbox wiki where there are some examples you can use, including initscripts for Fedora/Red Hat and for Debian/Ubuntu. It also has examples for how to set up Dropbox running under DJB's daemontools.

Get the PDF version of this tip here.


Vincent Danen works on the Red Hat Security Response Team and lives in Canada. He has been writing about and developing on Linux for over 10 years and is a veteran Mac user.


I'll be adding it to my Evernote.