Windows Mounting SSH as network drives, SSHFS, WIN-SSHFS, SSHFS-Win Manager

Windows Mounting SSH as network drives, SSHFS, WIN-SSHFS, SSHFS-Win Manager

SSHFS

"SSHFS allows you to mount a remote filesystem using SFTP. Most SSH servers support and enable this SFTP access by default, so SSHFS is very simple to use - there's nothing to do on the server-side."

Since I decided to publish a blog site, the biggest issue I faced was establishing my workflow. Grav appears to have some limitations on previewing 'blog type' posts, requiring me to spin up a dev version of the site. Because I am committed to setting up my lab in the most production-like way possible, I actually had no issues with this. This process requires me to edit on my dev site and sync the files across to the production site. This can be accomplished in many ways, just from the Linux side. Manual SCP, RSYNC, or Ansible/scripted approach would totally get the job done. I was considering which path to take.

At the same time, I wanted to solve a file-level backup issue I was trying to solve in my lab. My lab is on a separate VLAN that cannot initiate or talk to my management VLAN. This provided a challenge to push type backups to my mgmt side storage. I could allow traffic to my mgmt NAS from specific lab IP's. Honestly though I wanted to keep my lab "over there" and fairly isolated. The mgmt side of things are mostly Win machines, and main NAS is a Win based solution, I basically do scheduled file sync of large drives, this is not an enterprise solution, but for my requirements at home it works as I need it. I was looking for a 'pull' type backup solution.

One thing led to another, and I landed on a solution to mount SSH shares to Windows drives. SSHFS and more specifically SSHFS-WIN. This article focuses on my Windows use case (and t he windows port), however sshfs has been around in linux for years. Typically when I needed a mount in dev testing it would be SMB or NFS, but this can come in handy when you need a mounted share without installing or configuring any accompanying services.

The cool part about this solution is it solves a couple pain points for me:

  1. It enables me to mount any SSH connection as a Windows drive, which then allows me to leverage my already automated backup process.
  2. Using SSH as a Windows drive allows me to just drag and drop updates without having to jump to any other solution.
  3. There even is a GUI project if that's your thing SSHFS-Win Manager Which we will also check out.

I will take you through the install

Head on over to:
SSHFS-WIN
download SSHFS win that is correct for your workstation
WinFsp 2023
winFsp is a prerequisite install this first.
SSHFS-Win Manager
The GUI App

Once these are installed all there is left is to connect the drives. I tried the traditional method using explorer but even with root creds I could not access the root file system of the server I was trying to connect to. I ended up using the 'net use' command I will detail the syntax below. Its important to note, connecting with root creds in a production environment is not best practice (101), and in reality in the real world if you were to use this method for anything prod, you would assign specific permissions on the Linux side for the mount service. In the case of my lab I want full access, however in the future I shall test the access with reduced permissions for knowledge sake. Anyway on to the important stuff!

Once both packages are installed, from my experience its easy after that.

I for this example I will be using the 'net use' command, however with a couple of caveats. This method creates Network Locations not actual drives, for my use case its pretty meaningless, but it might matter to someone so I called it out. Also disconnecting these drives has proven cumbersome.

  1. Open a CMD Prompt as Administrator and use the following:
    net use X: \sshfs\root@your_ip\/ your_password
    Basically I have multiple lines/drives saved in text/bat file that I just run when I want to mount these drives.

Sample Image

Once the commands complete (very quick)

Sample Image

You will see the above. They mount in Network Locations, which not a functional issue for me, also the connections will be named after the IP you used to connect, one cool behavior is you can rename these to whatever you want and when you reconnect seem to keep the naming.

Sample Image

One thing I have observed if you want to disconnect drives mounted with SSHFS they don't disconnect gracefully, or in my case, at all. What I found is killing the process ssh.exe for each connection did the trick. In one case I still saw an orphan connection but restarted windows explorer and it was gone after restart.

Now lets check out the windows GUI

Open up SSHFS-Win Manager

Sample Image

and add a connection

Sample Image

Notice you can specify a drive letter, or leave the default as auto

Sample Image

Advanced has some good stuff like connecting after reboot, and reconnect on connection loss, it even will accept params

Sample Image

Once your connection is added click the connect icon

Sample Image

You will see your drive added as local disk.

Thats about it!

To my understanding, you can use native windows mount with SSHFS, but I immediately encountered some issues with that. You could also probably do some WSL stuff to accomplish this as well. This solution works dependably/repeatably so I will follow the path of least resistance.

Enjoy those drives ! ooohh yeah..