You ask — we answer!

How to mount a remote folder over SSH on different OSs

How to mount a remote folder

We often need to transfer files both to and from a dedicated server. For example, constantly uploading datasets or files for rendering to your server for testing purposes. If you do this regularly, it can result in certain problems.

Fortunately, there is a convenient way to solve this problem so that you can make changes right away. To do this, you need to mount a remote SSH folder to your local computer.

Let's see how to do this step by step.

1. Installing SSHFS

First, we need to install SSHFS. This is done in different ways on different operating systems.

Ubuntu/Debian: To install SSHFS, use the following command:

sudo apt-get install sshfs

Mac OSX: Install brew:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install FUSE:

brew cask install osxfuse

Now install SSHFS:

brew install sshfs

Windows: You will need to download the win-sshfs package. It is available here:

https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/win-sshfs/win-sshfs-0.0.1.5-setup.exe

2. Mount remote folder for Mac OSX /Ubuntu/Debian

In this case, the steps will be the same for both Mac OSX and Ubuntu/Debian. The steps will be slightly different for Windows, and we'll cover it at the very end of the guide.

First, we need to create a local directory where the file system will be mounted.

sudo mkdir /mnt/leadergpuserver 

We can now use sshfs to mount the file system locally. If your dedicated server was created with a username /password for login, then use the following command:

sudo sshfs -o allow_other,default_permissions root@xxx.xxx.xxx.xxx:/ /mnt/leadergpuserver 

If authorisation is done via SSH key, then you will need to set your public keys using the following command. (You will need to enter the password that you used when creating the keys.)

sudo sshfs -o allow_other,default_permissions,IdentityFile=~/.ssh/id_rsa root@xxx.xxx.xxx.xxx:/ /mnt/leadergpuserver 

You can now work with your remote directory on the server as if it were a directory on a local device. You can create a file in /mnt/leadergpuserver on your computer, and it will immediately appear on your dedicated server. You can copy/paste files to this folder on your computer, and they will be uploaded to the server in the background.

If the local machine or server was rebooted or stopped, then in this case you will need to go through the entire process again to re-mount the folder.

To unmount a remote directory, use the command:

sudo umount /mnt/leadergpuserver 

 It is also possible to permanently use a remote directory. To do this, you will need to open the /etc/fstab file on your local machine and edit it.

sudo nano /etc/fstab

Next, add the command to the very bottom of the file:

sshfs#root@xxx.xxx.xxx.xxx:/ /mnt/leadergpuserver 

Save changes and reboot.

Attention: Using permanent mounting of a remote directory is not recommended on production servers due to the high risk of compromise from attackers.

3. Mount remote folder for Windows

After starting the Win-SSHFS program, you will need to follow these steps:

  1. Click on Add in the lower left corner of the window.
  2. Enter the storage name in the Drive Name field.
  3. Enter the IP of the server in the Host field.
  4. Enter the SSH port (usually 22).
  5. Enter the username in the Username field.
  6. Enter the password for SSH in the Password field.
  7. Enter the desired mount point in the Directory field (if root is required, enter /. You can also enter /var/www or ~/ for your home directory).
  8. Select a drive letter that will be used in Windows.
  9. Click Mount to mount the file system.

Done! You should now see your new folder with the selected letter in My Computer. 



Updated: 19.04.2023

Published: 11.01.2021


Still have questions? Write to us!

By clicking «I Accept» you confirm that you have read and accepted the website Terms and Conditions, Privacy Policy, and Moneyback Policy.