To mount the file system of a remote server as a network drive in Windows, you can use the secure SSH protocol instead of the traditional SMB (Samba) connection. This is useful when you need to secure access files on a remote SSH server locally without creating a separate FTP (SFTP) connection. The SSHFS-Win client can be used to mount remote file systems in Windows via SSH. This client allows transparently map remote directories using the SSHFS protocol (based on SSH File Transfer Protocol, SFTP).
Download the SSHFS-Win MSI installer manually or install it using the built-in WinGet package manager:
winget install SSHFS-Win.SSHFS-Win
You can now mount a remote folder as a network drive directly from Windows File Explorer GUI. Right-click on This PC and select Map Network Drive. Select the drive letter to assign and the UNC path to the remote directory in the following format:
\\prefix\\user@host[!PORT][\\PATH]
user
– the user account used to authenticate to the remote SSH host
host
– host name/IP address
Use one of the following values as a prefix:
sshfs
– map the user’s home directory (the user’s profile directory on Windows). In addition, specify the relative path to any directory in the user profile (working dir).sshfs.r
– mount the root directory of the remote computer (for Windows, this refers to the root of the system drive).sshfs.k
– map the user’s home directory. SSH key in %USERPROFILE%/.ssh/id_rsa is used for authentication.sshfs.kr
– connect to the root directory with SSH key
For example, to map the C:\PS
directory from a remote Windows host with the SSH server enabled, enter the following UNC path
\\sshfs.r\[email protected]\ps
When connecting, you’ll be prompted to enter the remote user’s password for authentication (you can choose to save the password in Credential Manager)
After that, a separate network drive mapped via SSHFS will appear in Windows Explorer.
You can also map a network drive from the command prompt using the net use:
The following command mounts the /var/www
directory from a Linux host as a Windows network drive:
net use W: \\sshfs.r\[email protected]\var\www /user:sysops
net use m: \\sshfs.r\[email protected]\ps /user:administrator
You will be prompted for the user’s password during the connection.
A network drive mapped in this way persists only until the computer is restarted. Add the /persistent:yes
option to the command to automatically reconnect the drive when the user logs on.
cmdkey /add:192.168.123.123 /user:admin /pass:Passw0rdd1
Multiple network drives can be connected simultaneously using the WinFsp.Np provider. List the connected drives:
net use
Delete a mapped network drive:
net use M: /delete
In the net use command, you can specify the user password in plain text, but it’s more secure to mount the remote folder using SSH key authentication. Generate SSH keys on Windows using the ssh-keygen.exe
tool according to the manual at the link (do not specify a passphrase to protect the private key). Add the public key from the .pub file to the authorized_keys
(or administrators_authorized_keys
) file on the remote SSH server.
To automatically map a network drive over SSH using key authentication at Windows logon, you can create a scheduled task that runs a PowerShell script:
$remoteUser = "admin"
$remoteHost = "fs01.woshub.com"
$remoteDir = "\Install"
$Drive = "M:"
$privSSHKey = "C:\secret\fs01-id_rsa"
cd 'C:\Program Files\SSHFS-Win\bin\'
$mountcmd = ".\sshfs-win.exe svc \sshfs.k\$remoteUser@$remoteHost$remoteDir $Drive -IdentityFile=$privSSHKey"
Invoke-Expression $mountcmd
You can use a graphical client to map a network directory via SSH. The easiest and most convenient client is SSHFS-Win-Manager. It is possible to create multiple SSHFS connections to remote file systems using the SSHFS-Win-Manager client. It supports both password and key-based authentication.