How to Umount non-sudo SSHFS Created Directory?

The sshfs is the file system that mounts a remote directory over ssh. A non-sudo sshfs directory is a remote directory mounted locally using the SSH Filesystem (sshfs) utility without using the sudo command. The directory can easily be mounted, but it could get tricky regarding unmounting. This raises the question of how to umount a directory mounted using non-sudo sshfs. It is done using the fusermount command.

This guide explains how to unmount a directory created without sudo privileges.

  • Prerequisite: Install sshfs Command and Mount a Directory on Linux
  • Method 1: Using umount Command
  • Method 2: Using fusermount Command

Prerequisite: Install sshfs Command and Mount a Directory on Linux

The sshfs is not pre-installed on Linux but can be installed using these commands:

$ sudo apt install sshfs            #Ubuntu/Debian
$ sudo yum install fuse-sshfs       #CentOS/RHEL

The above image confirms the installation of sshfs on Ubuntu 22.04LTS.

Mount a Directory from a Local to Remote Machine

To mount a directory from a Local to Remote Machine Using SSHFS, follow this detailed guide. Here the remote directory named “rfolder” is mounted to the directory “office” on the remote host “[email protected]”:

$ sshfs [email protected]:rfolder ~/office

The above image indicates the successful mount of the rfolder directory to the office directory.

Method 1: Using the umount Command 

A method exists to unmount a remote directory created without sudo privileges with sshfs. It is done using the “umount” command which is a command line utility used to unmount a filesystem from a directory. Let’s discuss it:

Syntax:

$ umount [options] filesystem

In the above syntax, the umount enables the users to remove or unmount a remote file system.

To view a list of options, use this man command:

$ man umount

Now to umount a non-sudo sshfs created directory using the umount command (office directory as mounted earlier) execute this:

$ umount office

The output shows that the office directory has been unmounted.

Note: Some users may face errors like “Permission denied,” and if that comes up, use the fusermount command as follows.

Method 2:  Using the fusermount Command 

The fusermount is used to mount or unmount a FUSE filesystem. It allows non-root users to mount file systems and provides a mechanism for unmounting them without the need for root privileges. To unmount the fuser systems, the fusermount command is used in this way:

Syntax:

$ fusermount [OPTIONS] MOUNTPOINT

Here, the MOUNTPOINT is to be replaced with a directory where an external file system can become accessible to the user.

To view a list of options, use this man command:

To umount a non-sudo sshfs created directory using the fusermount command (office directory as mounted earlier). Here, the “-u” is used to unmount the “office” directory:

$ fusermount -u office

The above image confirms the successful unmounting of the office directory.

Conclusion

To umount a non-sudo sshfs created directory on Linux, the umount and fusermount commands are used. However, the umount command can output the error “Permission denied” due to the root privileges. So it is recommended to use the fusermount command to unmount the non-sudo sshfs created directory.

This guide explained the methods to umount a non-sudo sshfs created directory.