Create network drive using ssh to window env.

OK. Before I start on this one, I’m stating for the record that I’m posting this as much so I don’t have to find it again as anything. However, given the number of places online that I found this question asked, but not answered, I hope it proves useful to the folks who’ve been looking for it.

Enough babbling, on with the geeking.

Here’s the basic problem/challenge. While in an ideal situation, SFTP Drive looks nice, in reality, I’ve had problems with it during my 6 week trial that left me waiting till they work out some of the kinks. Most notably were the errors in connecting to this site after some sort of timeout. In those cases, I was entirely unable to connect to the site (even with disconnecting and reconnecting the SFTP Drive) without rebooting. Sorry, but that doesn’t fly.

However, I still would really like easy access to my remote machines’ files and preferably via SSH. So, since I had seen evidence of sshfs on Linux working at least on that end, I messed with that for a couple of days and finally got one of my virtual Ubuntu VMWare appliances to connect to via sshfs.

Then, yesterday morning a though occurred to me. What if I connected to the remote machines via sshfs on one of the Ubuntu machines and then shared the mounted directories via Samba. That way, I’d be able to map drives to these remote servers on my Windows workstations. I’d have *mapped drives to SFTP locations* by just going through a virtual Linux machine.

I went digging before work and got most of it working and finished the rest (though I do have a wishlist at the end for missing features) last night. It works. What follows is what needs to happen to make it work.

I started with an Ubuntu Server installation on VMWare Server, logged in as my one regular user. The virtual machine in question is my web development machine (mostly LAMP setup). SSH was already installed and working.

To install the sshfs package on the virtual machine:

sudo apt-get install sshfs

In order to be able to use the mounted directory as a regular user, you need to be added to the “fuse” group, which the package created:

sudo adduser your-username fuse

Note that the permissions change doesn’t actually work until you log off and back on. However, since a reboot is needed shortly, don’t worry about it.

Then, you need to create a directory for the remote mounted machine:

sudo mkdir /mnt/wyniaorg

sudo chown your-username /mnt/wyniaorg

Now, here’s the part that wasn’t in most of the tutorials, but necessary to make Samba work later on.

Create a file at /etc/fuse.conf

touch /etc/fuse.conf

Put the following line in /etc/fuse.conf:



To mount the remote directory, here’s the command that I use for

sshfs /mnt/wyniaorg -o allow_other

Note that I actually need to use a full email address to log in to this server, so the first “@” is part of the username and the second is the delimiter for the host. The “/var/www/html is the remote directory and “/mnt/wyniaorg” is the local directory on the virtual machine.

It’ll ask you for your password. For the moment, I’m going to have to type that in every time I mount the remote drive. There’s a potential solution out there, but it doesn’t work for the server this site sits on.

To avoid having to retype that beast of a commandline repeatedly, I saved the command as


Then make it executable:

chmod +x ~/scripts/

To run that script:

cd ~/scripts


I also created a script to unmount the directory:

fusermount -u /mnt/wyniaorg

and put it as “”, also making it executable.

To install Samba:

sudo apt-get install samba smbfs

To share the mounted drive, you need to edit the Samba config file:

sudo pico /etc/samba/smb.conf

I wanted to not have to enter a password to access the shared drive, so in /etc/samba/smb.conf, I set the security to

security = share

and then added a section at the end of the file for my new share.


comment = wyniaOrg

path = /mnt/wyniaorg/

public = yes

writable = yes

create mask = 0777

directory mask = 0777

force user = nobody

force group = nogroup

I also added a section to share the /var/www directory of the virtual appliance itself:


comment = PHP Dev Server WWW

path = /var/www/

public = yes

writable = yes

create mask = 0777

directory mask = 0777

force user = nobody

force group = nogrou

Then, to open the files, I’ve already got the IP address in my hosts file (C:\WINDOWS\system32\drivers\etc\hosts): php

So, in Windows Explorer, I can just:


and I see my remote directory and the public share right there in Windows.

If the remote directory isn’t mounted, you just get an empty directory. This is good because, as long as the Linux/Samba portion is up and running, Windows will map to the directory without complaining: there just won’t be anything in there. This is good fallback behavior and beats the heck out of what Windows does when it can’t find the network share at all. All that freaking out with warning dialog after warning dialog drives me nuts.

If you want to make the mapping of the drive semi-automatic, you can create a Powershell (more on this amazing addition to Windows in a couple of days) script called something like “map_wyniaorg.ps1″ containing this code:


$Drive = “J:”

$UNC = “\\php\wyniaorg”

# Create the Com object with New-Object -com

$net = New-Object -com WScript.Network;

# $net.removenetworkdrive($Drive)


# Launches the Explorer

$shell = new-object -comObject Shell.Application


While I’ve gotten ssh without a password to work *between* the Ubuntu VMWare servers I’ve set up (using the instructions all over the web), I haven’t gotten it to work with the ssh setup. So, for now, I just deal with the password thing.

If the lazy web wants to grant my wishes, what I still want is the easy way to:

1. Do the sshfs mounting automatically.

2. Without passwords.

3. Without logging on to the machine.

4. At bootup.

5. And to make sure that cleanup is done properly at shutdown.

Oh, and I probably missed something, which will become clear the next time I want to do this on a machine and come back to this article. However, if you have a problem, let me know and I’ll update.

thanks to:


Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/enamyid/public_html/ on line 5373

Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /home/enamyid/public_html/ on line 5373