How to Mount Remote Directories over SSH via SSHFS on Ubuntu Linux



The post provides a tutorial on using SSHFS (SSH Filesystem) to securely access remote directories on Linux systems, including Ubuntu. Using existing SSH servers, no additional setup is required for creating remote directories. The steps include installing SSHFS, mounting and unmounting directories, and if desired, permanently mounting a remote folder.

This brief tutorial shows students and new users how to install and configure SSHFS on Ubuntu 18.04 | 16.04 LTS servers.

Many different methods are available when accessing remote directories on Linux systems, including Ubuntu. If you want to make folders accessible to remote users and do it securely, you can use sFTP.

For Linux clients, SSHFS (SSH Filesystem) is another excellent tool. It is a sub-system with an SSH server and is enabled by default, based on FUSE, for mounting remote directories over an SSH connection.

Instead of setting up an entirely new server or process for making remote directories and folders available to users, you can use your existing SSH server—no need for additional configurations or FTP servers.

When you’re ready, follow the steps below:

Installing SSHFS on Ubuntu

SSHFS packages are available in Ubuntu’s default software repositories. So all you need to do to install it is to run the commands below:

sudo apt update
sudo apt install sshfs

After installing it, continue below to learn how to mount directories.

Mounting SSHFS Directories

Now that SSHFS is installed, you can use the mount command to access remote directories over SSH via SSHFS.

The SSHFS mount command format is shown below:

sshfs [user@]host:[remote_directory] mountpoint [options]

To mount a remote directory locally on your Ubuntu machine, you first create a location or mount point that will be synced with the remote side.

Run the commands below to create a folder called sshfs in your home folder. This is where the remote folder will be mounted and accessed locally.

mkdir $HOME/sshfs

You can then use the count commands to mount the remote directory locally through SSHFS.

sshfs richard@ $HOME/sshfs

Replace “richard” with the username created on your server and “” with the actual IP address of your remote instance.

To unmount the directory above, you run the commands below:

cd && fusermount -u $HOME/sshfs

To avoid typing the password each time you mount the remote directory, read this post to learn how to configure SSH key authentication. With it, you won’t have to time your password whenever you want to mount the remote directory.

Permanently Mount Remote Folder on Local Machine

If you want to mount the remote directory permanently, you need to edit the local machine’s/etc/fstab file and add a new entry. This will always keep the mount point available even if you reboot your machine.

This way, when your system boots up, it will automatically mount the remote directory.

Use fuse to mount a remote directory over SSHFS from /etc/fstab. sshfs as the filesystem type.

Run the commands below to open the /etc/fstab file.

sudo nano /etc/fstab

Then, add the line below to the file and save it.

sshfs richard@ $HOME/sshfs fuse.sshfs  defaults  0  0

You should ensure that password-less SSH authentication is enabled on the SSH server you’re connecting to so you don’t always have to enter a password.

Windows users can mount the remote location using the commands below and programs like SSHFS-Win and WinFsp.


That should be it!

Congratulations! You have successfully installed and enabled SSHFS and mount remote directories.

You may also like the post below:

Like this:

One response to “How to Mount Remote Directories over SSH via SSHFS on Ubuntu Linux”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.