Mounting remote directory over SSH on Windows

Mounting remote directory over SSH on Windows

The Problem:

You have a server only accessible via ssh and you want to use your favorite IDE.

On Ubuntu you can naively mount ssh accessible servers as SFTP locations but on Windows it is more complicated.

I have tried solutions like codeanywhere that let you work in the browser on files mounted via ssh to their cloud servers. However, in my experience, this service was flaky and I finally got fed up with all the downtime it caused.

Obviously WinSCP is an option and you can have it sync between a remote directory and a local directory. However, this can get messy and occasionally the folder sync gets messed up when files are being changed locally and on server. Then, of coarse, there is when you accidentally sync the wrong way undoing past work. If you use multiple machines to develop on, then you are either keeping your sync folders all in order or doing a samba share from the one running WinSCP. That can be a headache.

I wanted a solution that required no extra steps in my development process.

The Solution:

Enter WinSshFS. You can use it to actually mount the remote directory as a local directory. This allows you to work directly on the server using a local IDE as if it were a local directory.

As of the time of this article, 2017-11-19, the best experience I had setting up WinSshFS was to download the “ devel RC5” from Grab the WinSSHFS- file and run it when downloaded.

You must also install the dependancy Dokan version “1.0.5” from Grab the Dokan_x64- file and run it when downloaded.

Once finished, WinSshFS is ready to be used. The easiest way to run it is to press the windows key to open the Windows search and type “WinSshFS”.

Creating a new connection is pretty straightforward except that if you are using an SSH private key file that you made using PuTTYgen, you need to load that private key in PuTTYgen and under Conversion you must export an OPENSSH version of it to use in WinSshFS.

Set the directory setting to the directory on the server you wish to mount and then click mount. You can now browse to this new drive on your computer using your preferred IDE.

You can tell WinSshFS to auto mount the remote location on login but obviously this is a security risk in the event that your dev machine gets compromised so this should be avoided when connecting to production servers.