Difficulty: Easy
Estimated Time: 15-20 minutes

If a distributed team needs to share the same data among its members, a common approach is to use some kind of data storage, like those offered by Amazon S3, Google Cloud Storage, Azure Blob Storage, IBM Cloud Object Storage, HDFS, etc. If the data are not too big, you may also use Google Drive, DropBox, etc. to synchronize with a single account.

There are also free applications that can be installed on your own server, like:

For a more comprehensive (but not ultimate) list of the available options see https://rclone.org/#providers

However another approach is to mount a remote directory on all the members of the team. This can be done with a network filesystem (like NFS, SMBFS, SSHFS, etc.), or with some distributed filesystem.

In this tutorial we will see how to share data with the help of SSHFS, which is really easy to setup and convenient. All the members of the team (2 in our example) will mount through SSHFS the same directory from a central server, as shown in the following diagram:

Sharing Data With SSHFS

Step 1 of 5

Step 1

Setup the central server

In this step we are going to setup the server. In the following steps we will do the setup for the first user and the second user.

  1. Create user accounts.

    For each user that needs to access the central data storage we will create an account on the server. Let's assume that we have two users and their accounts are named user1 and user2.

    useradd -m -s /bin/bash user1

    echo user1:pass1 | chpasswd

    ls -al /home/user1/

    Create also the second user:

    useradd -m -s /bin/bash user2

    echo user2:pass2 | chpasswd

    ls -al /home/user2/

  2. Add the users to the same group, in order to manage their permissions:

    addgroup data

    adduser user1 data

    adduser user2 data

  3. Create a directory for the data storage and set proper permissions to it:

    mkdir -p /srv/data

    ls -al /srv/data

    chgrp -R data /srv/data

    chmod -R g+rw /srv/data

    chmod -R g+s /srv/data

    ls -al /srv/data

    Notice the setgid permission that we set on the data dir. Because of it, the new sub-directories or files that are created inside the repo dir will have the same group as the data dir. This is convenient for a group of users that use the same directory.