SSHFS is a Linux tool for mounting remote folders over SSH. It allows users to manage network-shared files just like local ones. This tool is secure and efficient, providing seamless management of network shared folders across different environments.
Before you start, ensure you have:
Root or sudo permissions.And if you’re looking for a reliable, high-performance, and budget-friendly solution for your workflows, Hostman has you covered with Linux VPS Hosting options, including Debian VPS, Ubuntu VPS, and VPS CentOS.
First, install SSHFS on your local system through the package manager. This tool installation on the other system is not needed.
On Ubuntu/Debian:
sudo apt install sshfs

On CentOS/RHEL:
sudo yum install sshfs
Set up a folder in your home or any desired location. This will act as the connection point for the network shared directory.
sudo mkdir remote_dir

Attach the linked folder to the local computer for seamless access. Use the below-given command to perform remote filesystem mounting:
sudo sshfs -o [options] user@host:/remote_path /local_mount
Substitute user with your real remote server’s username, host with the IP address or hostname of the server, and /remote_path with the directory path you want to connect. The [options] include:
allow_other: Grants access to other local machine users for accessing the mounted folder.reconnect: Automatically re-establishes the connection in case it drops.IdentityFile=/loc/of/private_key: Specify the location where SSH private key is stored.idmap=user: Aligns the ID of remote user to the local user ID.default_permissions: Applies the remote file system's default permissions.To connect the linux home folder from 192.X.X.X to /home/ubuntu/remote_dir, utilize:
sudo sshfs -o allow_other,default_permissions linux@192.X.X.X:/home/linux/ /home/ubuntu/remote_dir/
To employ an SSH key found at /home/ubuntu/.ssh/id_rsa, use:
sudo sshfs -o allow_other,default_permissions,IdentityFile=/home/ubuntu/.ssh/id_rsa linux@192.X.X.X:/home/linux/ /home/ubuntu/remote_dir/
Type 'yes' to accept the server’s fingerprint and add it to known hosts.

Enter the password for authentication. Use the key if set up.

After verification, the folder will be linked to the local path.

Create a new folder or file in the attached directory and verify its existence on the external server.

If the folder or file appears in the external server's directory, the operation is successful. This ensures changes in your local directory are mirrored on the external system.

If you experience the "Permission denied" error when trying to create or modify an existing file, follow these instructions to resolve it:
Run the ls -l command to view the current permission of files or directory.
Execute the chmod command to modify the permissions.
sudo chmod 644 /path/to/file_or_directory
If the file or directory is owned by another person, run the chown command to change the ownership.
sudo chown your_username /path/to/file_or_directory
Once finished, simply unmount the folder:
sudo umount /remote_directory

Below are some additional things you can also do:
To automatically connect remote filesystem at startup, utilize these steps:
Access the /etc/fstab file with elevated privileges:
sudo nano /etc/fstab
Append an entry to the end of the file:
user@remote_host:/remote/directory /local/mount/point fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,allow_other,reconnect 0 0
Example:
linux@192.X.X.X:/home/linux/ /home/ubuntu/remote_dir fuse.sshfs noauto,x-systemd.automount,_netdev,users,idmap=user,allow_other,reconnect 0 0
Where:
noauto: Automatically stops the mount from happening at boot.x-systemd.automount: Uses systemd to dynamically connect the filesystem upon access._netdev: Indicates that network access is required for the process.users: Grant non-root users the ability to mount and unmount.idmap=user: Associates external user with local one.allow_other: Permits another person from retrieving the connected directory.reconnect: Ensures automatic reconnection in case connection drops.Make sure the local mount point directory exists, and if not, create it:
sudo mkdir -p /home/ubuntu/remote_dir
Test the connectivity:
sudo mount -a
This command initiates the connection of all filesystems listed in /etc/fstab. If no errors arise, the process is successful.
SSHFS usually utilizes SFTP for transferring. To bypass this, run:
sshfs -o sftp_server=/usr/lib/openssh/sftp-server user@host:/remote_directory ~/remote_mount
To save commonly used options, create a .sshfs_config file in your home location. This will allow you to store and easily apply your preferred settings.
nano ~/.sshfs_config
Add your options and connect via the configuration file.
sshfs -F ~/.sshfs_config username@remote_host:/remote/directory ~/remote_mount
Below are some common problems and solutions.
To ensure seamless connectivity, make certain that SSH service is configured in the correct way on both your local and external systems. Also, check that the service port is open and that your firewall settings allow access, which is crucial for maintaining an uninterrupted connection.
For better performance, use the -o direct_io and -o cache=yes options.
sshfs -o direct_io -o cache=yes user@host:/remote_directory ~/remote_mount
To utilize SSHFS for Windows, follow these instructions:
Download and set up SSHFS-Win from this location.
Right-click on This PC and go with the option Map network drive from the context menu:

Choose an available drive letter from the menu. In the Folder field, input the command as follows:
\\sshfs\user@host\remote_path
Click Finish to complete the mapping process.

Enter your credentials and provide the required username and password (or SSH key, if configured).
Once connected, access the directory via Windows Explorer.

Here are the additional options for the sshfs command based on different used cases:
sshfs: Integrates the remote home directory locally.sshfs.r: Links to the remote server's root directory.sshfs.k: Uses [local-user]/.ssh/id_rsa to map the remote home directory.sshfs.kr: Utilizes a locally stored SSH key to access the root directory.When finished, right-click the network drive and choose Disconnect to detach the directory.

SSHFS provides an efficient and secure method for mounting remote file systems through SSH. This guide helps you set up and use this tool to improve file management on Linux systems. Whether performing the SSHFS mount as root, avoiding SFTP, or utilizing configuration files, this tool offers flexibility and control for various scenarios.