In the latest Windows release "Fall Creators Update" it is possible to mount UNC paths, or any other filesystem that Windows can access, from within WSL.
You can do this with the
mount command as usual, with the filesystem "
drvfs" provided by WSL:
sudo mount -t drvfs '\\server\share' /mnt/share
Single quotes are useful around the UNC path so that you don't have to escape the backslashes. You can mount on an arbitrary directory; I've used
/mnt/share as an example here, but any empty directory will do.
All files will show up with full
777 permissions. The real access rights will be checked when you try to access a file, and you can get an error at that point even if it looks like the operation should succeed. Every readable file will be treated as executable.
For locations that require credentials you have three options:
- Prior to mounting, navigate to the location using Windows' File Explorer and authenticate. WSL will inherit your credentials and permissions. This is the easiest way for a one-off.
- Use the
net use command from a cmd prompt, or
net.exe use from inside WSL (
cd /mnt/c first to suppress a warning). You'll need something like
net.exe use \\server\share <PASSWORD> /USER:<USERNAME>. You can use
'*' for the password to be prompted instead. Other configurations are shown with
net.exe help use.
- Use the Windows Credential Manager to set up a stored credential. I've never done this one.
I understand that Samba proper can be made to work under WSL as well, but since the host provides the same functionality I would use the built-in version from Windows when it's available.
smbclient is primarily for FTP-style access to SMB servers and retrieving/putting individual files, and it should work when appropriately configured as usual.