36. SSHFS – a powerful tool for system administration

by Double Bastion - Updated March 27, 2021
SSHFS (SSH Filesystem) is a filesystem client that allows mounting remote directories and files over a SSH connection.

With SSHFS you can mount all the directories of your remote server on your local computer, so that you can edit, copy, move, create, compress, etc. any remote files or directories, as if they were located on your local Linux computer. So, if you use Linux on your laptop/desktop, when you want to quickly access and edit files on the remote server, or you need to copy numerous files or folders, to/from the remote server, instead of using a FTP client, you can just use SSHFS to mount all the remote directories in a specific directory on your local computer, and then access the remote directories as if they were local. You will also be able to use GUI text editors like Mousepad or Pluma, which allow mouse actions, to edit files much faster than with command line text editors like nano.

If you use Debian on your local computer (which we recommend), first install SSHFS by running:

apt-get install sshfs

Then create a directory where you want to mount the remote directories:

mkdir /mnt/remote

To mount all the remote directories in the newly created folder, run:

sshfs -p 6283 root@ /mnt/remote -o allow_other

where 6283 is your custom SSH port and is the public IP of your server. Then, open your file browser and navigate to /mnt/remote. You will see all the directories of the remote server and you will be able to access and modify them as if they were local directories:


If you had wanted to mount just the /var/www remote directory to your local folder, you would have run:

sshfs -p 6283 root@ /mnt/remote -o allow_other

After you finish working with the remote directories and files, you can unmount them manually, by running:

umount /mnt/remote

or you can just power off your local computer, which will unmount them. 

By using SSHFS you won't be able to run commands or launch programs on the remote server.

Please note that in order to use SSHFS, you will have to temporarily allow SSH access for the root user. As we mentioned at the beginning of this guide, for security reasons, the root user should be denied SSH access, by setting   PermitRootLogin no   in the  /etc/ssh/sshd_config  file. Yet, if you want to use SSHFS to easily access and edit remote files and directories, you can temporarily allow SSH access for the root user. When you finished your work, you can disable SSH access for root by editing the /etc/ssh/sshd_config file again, turning  PermitRootLogin from yes to no, then restarting  sshd  with  systemctl restart sshd .