All Products
Search
Document Center

Object Storage Service:Mount an OSS bucket as a non-root user with ossfs

Last Updated:Feb 27, 2026

By default, ossfs runs as the root user. To let a specific system user (such as www) own the mounted directory, mount the bucket as that non-root user. This topic walks through the full procedure on a Linux-based Elastic Compute Service (ECS) instance.

Prerequisites

Before you begin, make sure that you have:

  • An ECS instance running Linux

  • An OSS bucket

  • ossfs installed on the ECS instance. For more information, see Installation

  • The /etc/passwd-ossfs credentials file created with valid AccessKey credentials in the format <bucket-name>:<access-key-id>:<access-key-secret>

  • Root or sudo access for initial configuration

Procedure

This procedure uses www as an example non-root user. Replace www with your target user throughout.

Step 1: Create the non-root user

Skip this step if the user already exists.

useradd www

Step 2: Get the UID and GID of the target user

Run the id command to get the UID and GID:

id www

The output is similar to:

uid=1001(www) gid=1001(www) groups=1001(www)

Record the uid and gid values. You need them in the mount command.

Step 3: Configure credentials file permissions

Set the permissions to 640 and change the owner to the target user:

chmod 640 /etc/passwd-ossfs
chown -R www:root /etc/passwd-ossfs

Step 4: Find the ossfs binary path

Run the following command to confirm the installation path:

which ossfs

The default path is /usr/local/bin/ossfs. Use the actual path returned if it differs.

Step 5: Create a mount directory

Switch to the target user and create a directory for the mount point:

su - www
mkdir ~/test1
This example uses test1 as the directory name. Replace it with your preferred name.

Step 6: Mount the bucket

Run the following command as the www user:

/usr/local/bin/ossfs <bucket-name> ~/test1 \
  -ourl=<endpoint> \
  -ouid=<uid> \
  -ogid=<gid> \
  -o passwd_file=/etc/passwd-ossfs \
  -odefault_permission=750

The following table describes each parameter:

ParameterDescriptionExample
<bucket-name>Name of the OSS bucket to mountmy-bucket
<endpoint>Endpoint of the region where the bucket is locatedhttp://oss-ap-southeast-1.aliyuncs.com
<uid>UID of the target user, from Step 21001
<gid>GID of the target user, from Step 21001
passwd_fileAbsolute path to the credentials file/etc/passwd-ossfs
default_permissionDefault permission mode for the mounted directory750

Step 7: Verify the mount

List the mount directory to confirm that the bucket is mounted and the ownership is correct:

ls -l ~/test1

If the mount succeeds, the output shows the contents of your bucket with the www user as the owner.

Unmount the bucket

Use one of the following methods to unmount the bucket:

  • As the root user:

      umount /home/www/test1
  • As a non-root user:

      fusermount -u /home/www/test1
Replace /home/www/test1 with the actual absolute path of your mount directory.

References