U of I Box, Using Box under Linux

An overview of options for using U of I Box with Linux.

Even though there is no Box Sync for the Linux platform, U of I Box can still be used effectively from Linux desktops using the web browser, FTP, and WebDav access. (Sections of this document have been borrowed with permission from https://uisapp2.iu.edu/confluence-prd/display/SOICKB/Using+Box+under+Linux.)

Web Browser Access

You can access your U of I Box account through a web browser on your Linux desktop at https://box.illinois.edu. Using this url provides the convenience and security of single sign-on with your Illinois NetID. While the web interface may not be ideal for all applications, it does give you access to your account as well as the ability to preview, upload, and download files.  There is no Box Edit for Linux so that functionality is not available.

If using the below options, please set your "External Box password" (This can be created under "settings" when you are logged into Box)

WebDAV Access (Cadaver)

Cadaver is a command-line WebDAV client that allows access to your Box account. You can use the cadaver command as follows:

cadaver https://dav.box.com/dav

When prompted, just enter your username (like NetID@illinois.edu) and your external Box password.

Once you get logged in, you can use a number of standard ftp-like cadaver commands like ls, get, and put. Type 'help' to get a list of commands and 'help command' to get help for an individual command.

While we never recommend putting cleartext passwords in files, do note that it is possible to set usernames and passwords for cadaver via the ~/.netrc configuration file login and password tokens. This would allow unattended upload and download of files and could be used for things like scripting and cron jobs. See the description of the .netrc file in the cadaver man page for details.

WebDAV Access (lftp)

Please note that you should never use the standard FTP protocol with ftp.box.com since your login credentials will be transferred across the network in clear text.

The lftp command is a powerful file transfer client that can be used with Box.  Box supports the secure FTPS protocol and you can use this with lftp for secure file transfer and mirroring.  Here is an example of how to connect using FTPS.  The lftp command is smart enough to auto-negotiate to use FTPS but this example forces the issue to make absolutely sure unencrypted FTP is never attempted.

$ lftp
lftp :~> set ftps:initial-prot ""
lftp :~> set ftp:ssl-force true
lftp :~> set ftp:ssl-protect-data true
lftp :~> open ftps://ftp.box.com:990
lftp ftp.box.com:~> user NetID@illinois.edu
lftp NetID@illinois.edu@ftp.box.com:~> ls

Once you are connected, you can use normal FTP commands like ls, get, put, etc.

One interesting application of lsftp with Box is using it to mirror a local directory similar to what Box Sync does, albeit in a more manual way.  The best way to explain this is by example so here is a sample script that mirrors a local /u/username/MyProject directory to Box into a folder of the same name (MyProject):

lftp -c 'open -e "set ftps:initial-prot ""; \
   set ftp:ssl-force true; \
   set ftp:ssl-protect-data true; \
   open ftps://ftp.box.com:990; \
   user NetID@illinois.edu; \
   mirror --reverse --delete --no-perms --verbose "/u/username/MyProject" MyProject;" '

When you run this script, it will prompt for a password and then mirror your local directory to Box.  Each time you run it, it will re-sync any changes on the local filesystem with the copy on Box.  The --verbose option causes lftp to tell you exactly what it is doing.  If you are doing this via crontab, you probably want to remove that and you will also need to pass along the password in the script so do that with caution.

Note that when using this method, you may have it fail with this message:

Login failed: 530 Box: CAPTCHA is required. Please log into www.box.com in a web browser, and then try again.

If that happens, just go to https://box.illinois.edu and log in using your campus credentials.

WebDAV Access (Nautilus)

Note that this does not work reliably on Red Hat Enterprise Linux 6 so you should upgrade to Red Hat Enterprise Linux 7 before using this option.

You can use the nautilus file manager in Gnome to access your Box space. There are a number of ways to do this but on the SoIC Red Hat Linux 7 systems you can do the following:

  1. From the Places menu, select any option to bring up Nautilus
  2. Select Connect to Server
  3. For  Server Address enter: davs://NetID%40illinois.edu@dav.box.com/dav (The '%40' is the character encoding for '@' and you must leave that there exactly as shown.)
  4. Click Connect and, when prompted, enter your external password for Enterprise Box.
This should bring up a File Browser window showing you the files you have in your Box space.

Mounting Box (davfs2)

Note that this does not work reliably on Red Hat Enterprise Linux 6 so you should upgrade to Red Hat Enterprise Linux 7 before using this option.

If you want to mount your Box space onto a directory so you have transparent filesystem access, you can do this using davfs2. The steps are detailed below. The first section lists configuration steps requiring root/sudo privileges.

DAVFS Setup Steps Requiring Root Access

  1. Install davfs2 - The davfs2 package will need to be installed. These instructions assume you have version 1.4.7 or newer.
  2. You need to create a directory you will use as the mount point. On the unified linux systems your home directory is mounted from a central file server so we recommend that you do not use a directory within your normal home directory.
  3. You need to be added to the davfs2 group.
  4. Add the "use_locks 0" configuration option to /etc/davfs2/davfs2.conf.
  5. You then need to add an entry to /etc/fstab that looks like:
https://dav.box.com/dav/ /home/username/box  davfs  rw,user,noauto 0 0

DAVFS Setup Steps To Be Done By The User

  1. Copy the /etc/davfs2 directory to .davfs2 in your home directory using the command: cp -r /etc/davfs2 ~/.davfs2 (Note that you will get a permission denied error on the secrets file but that can be ignored.)
  2. Create a file (using your favorite editor) named secrets in the .davfs2 directory that contains a single line using one of the following formats:
https://dav.box.com/dav box_username
https://dav.box.com/dav box_username  "box_password"
    box_username = Your box username
    box_password = Your box password

You are strongly advised to use the first format that omits the password. When using this format, you will be prompted for your password when you run the mount command. If you need unattended access without prompting for a password you can include the password. If you do include your password, you MUST make sure this file is not readable by others which you can do with:

$ chmod 600 ~/.davfs2/secrets

DAVFS Mounting and Unmounting

Once all of this setup is done, you can then mount and unmount your Box filesystem as follows and no root/sudo access is needed.

To mount:
mount /home/username/box
(You may see an error about writing to mtab which you can ignore)
To unmount:
fusermount -u /home/username/box

The argument to the mount and fusermount commands must match exactly the second entry on the line you added to /etc/fstab above.

You are strongly advised to unmount the filesystem when not in use.

Keywords:Box, U of I Box, Linux, FTP, WebDav   Doc ID:60950
Owner:Isaac G.Group:University of Illinois Technology Services
Created:2016-02-18 10:01 CSTUpdated:2017-10-27 11:56 CST
Sites:University of Illinois at Chicago ACCC, University of Illinois at Springfield, University of Illinois System, University of Illinois Technology Services
Feedback:  3   0