Using Box on Linux with Rclone

An alternative to using secure lftp for file transfers in Linux is to use Rclone.  Once you are set up with Rclone, file transfers are pretty straightforward.

 

Initial setup of Rclone

Follow the steps below to setup Rclone.

1. Log into an OSU Linux system using ssh (Mac) or MobaXterm or Putty (Windows).

2. Rclone may already be installed and in your default executable path.  To check, type:

which clone

If it is not installed, it may also be available to you through the modules system.  Load the "rclone" module to load the rclone application into your shell environment, e.g.:

module load clone

3. To configure Rclone, type:

rclone config

4. Type "n" to create a new remote instance, e.g. your OSU Box drive:

5.  Enter a name for the remote instance, e.g. "osu_box"

6.  Enter "6" for type of storage to configure.

7.  Press Enter for default client_id.

8.  Press Enter for default client_secret.

9.  Press Enter for default box_config_file.

10.  Press Enter for default access_token.

11.  Type "user" for box_sub_type.

12.  Type "n" for Edit Advanced Config.

13.  Type "y" for Use auto config.

14.  A browser window will open up to the Box web site.  Enter your ONID@oregonstate.edu and password with external applications.

15. The browser will be redirected to the OSU authentication page.  Enter your ONID credentials.

16. Click the blue button "Grant access to Box" to grant rclone access to Box.

17. Close browser window.

18. Type "y" to accept the new token.  Your new remote "osu_box" should now be listed as a remote cloud destination.

19. Type "q" to quit rclone config.

20. Congrats, you are finished and ready to use Box under Linux!  Continue reading instructions below for examples of using Rclone to access and transfer files to and from Box in Linux.

 

Using Rclone within Linux

To list remote accounts configured with rclone:

rclone listremotes

To list directories in your Box drive (e.g. osu_box):

rclone lsd osu_box:

To list all files in your Box drive:

rclone ls osu_box:

To list all files in directory "myDir" in your Box drive:

rclone ls osu_box:myDir

To copy the contents of your directory "myDir" to Box:

rclone copy myDir osu_box:

To copy the contents of your directory "myDir" from your Box account to Linux:

rclone copy osu_box:myDir myDir

To sync the contents of your directory "myDir" with your Box account:

rclone sync myDir osu_box:myDir

To see more Rclone options, type:

rclone 

 

Notes:

 - be advised the copy behavior of Rclone is slightly different than scp and rsync, so pay attention to what it does so you know what to expect from it.

 - Box has case-insensitive filenames, important when working with Linux which uses case-sensitive filesystems.

 - the token from Box created during "rclone config" expires every 60 days, so users will need to re-run "rclone config" every now and then to renew the token.

 - in principle Rclone is capable of mounting a remote folder onto your local directory in Linux, but it does not appear to work for Box accounts (i.e. it hangs, but interruptible with CTRL-C).

Check out this link for more information on configuring Rclone, and this link for more Rclone command options.