Top Tags

Mount SSH folder on Windows

Mount SSH folder on Windows

Overview

SSHFS (SSH Filesystem) allows you to mount remote directories over SSH on Windows, creating a network drive that behaves like a local filesystem. This is particularly useful for developers working with remote Linux servers, enabling seamless file access without manual file transfers.

Key Benefits:

  • Real-time file synchronization
  • Uses existing SSH authentication (password or key-based)
  • No additional server-side configuration required
  • Works with any SSH-enabled server
  • Supports Windows Explorer integration

Prerequisites

Before installing SSHFS-Win, ensure you have:

  • Windows 10 version 1803 or later (Windows 11 recommended)
  • Administrator privileges for installation
  • Active SSH connection to the remote server
  • WinFsp (Windows File System Proxy) - automatically installed with SSHFS-Win

Install SSHFS

SSHFS-Win is built on top of WinFsp, which provides the kernel-mode filesystem driver that enables user-mode filesystems on Windows. The installation package includes both components.

bash
1winget install SSHFS-Win.SSHFS-Win

Alternative Installation Methods:

Using Chocolatey:

powershell
1choco install sshfs

Manual Installation:

  1. Download from GitHub Releases
  2. Install WinFsp first (included in installer)
  3. Install SSHFS-Win

Post-Installation Verification:

powershell
1# Check if SSHFS service is running
2Get-Service | Where-Object {$_.Name -like "*sshfs*"}
3
4# Verify WinFsp installation
5Get-ItemProperty HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.DisplayName -like "*WinFsp*"}

Mount folder

The \\sshfs\ prefix is a special UNC path that SSHFS-Win recognizes. When you access this path, Windows redirects the request to the SSHFS-Win service, which establishes an SSH connection and translates filesystem operations.

bash
1net use Z: \\sshfs\user@host\path
2
3# or
4

Advanced Mounting Options

Mount with Custom SSH Port

If your SSH server runs on a non-standard port (default is 22):

powershell
1# Using port 2222
2net use Z: \\sshfs\user@host!2222\path
3
4# Example with IP address and custom port
5net use Y: \\sshfs\[email protected]!2222\home\admin

Mount with SSH Key Authentication

For key-based authentication, SSHFS-Win uses the SSH agent or looks for keys in %USERPROFILE%\.ssh\:

powershell
1# Ensure your private key is loaded in the SSH agent
2ssh-add "C:\Users\YourName\.ssh\id_rsa"
3
4# Then mount normally
5net use Z: \\sshfs\user@host\path

Mount with Specific Options

You can pass additional SSH options using the extended syntax:

powershell
1# Mount with specific identity file
2net use Z: "\\sshfs\user@host\path?IdentityFile=C:\Users\YourName\.ssh\custom_key"
3
4# Mount with compression enabled (faster for slow connections)
5net use Z: "\\sshfs\user@host\path?Compression=yes"
6
7# Combine multiple options
8net use Z: "\\sshfs\user@host!2222\path?IdentityFile=C:\ssh\key&Compression=yes"

Mounting at Startup

Using Task Scheduler

Create a PowerShell script for automatic mounting at login:

powershell
1# Save as: mount-ssh-drives.ps1
2
3# Define your mount points
4$mounts = @(
5 @{
6 Drive = "Z:"
7 Path = "\\sshfs\[email protected]\home\user"
8 },
9 @{
10 Drive = "Y:"
11 Path = "\\sshfs\[email protected]\var\www"
12 }
13)
14
15foreach ($mount in $mounts) {
16 try {
17 # Check if drive already exists
18 if (!(Test-Path $mount.Drive)) {
19 net use $mount.Drive $mount.Path /persistent:yes
20 Write-Host "Mounted $($mount.Drive) successfully"
21 } else {
22 Write-Host "$($mount.Drive) already mounted"
23 }
24 } catch {
25 Write-Warning "Failed to mount $($mount.Drive): $_"
26 }
27}

Make Mount Persistent

To automatically reconnect the drive after reboot:

powershell
1# Enable persistent connection
2net use Z: \\sshfs\user@host\path /persistent:yes
3
4# List all persistent connections
5net use
6
7# Remove a persistent connection
8net use Z: /delete

Troubleshooting

Common Issues and Solutions

Connection Timeout:

powershell
1# Increase timeout (in seconds)
2net use Z: "\\sshfs\user@host\path?ServerAliveInterval=60&ServerAliveCountMax=3"

Permission Denied:

powershell
1# Check SSH connection first
2ssh user@host
3
4# Verify file permissions on remote server
5ssh user@host "ls -la /path/to/folder"

Drive Letter Already in Use:

powershell
1# List all mapped drives
2net use
3
4# Disconnect specific drive
5net use Z: /delete
6
7# Or disconnect all network drives
8net use * /delete

Performance Optimization

For Large File Operations:

powershell
1# Enable caching and increase buffer size
2net use Z: "\\sshfs\user@host\path?cache_timeout=115200&cache=yes"

For Better Compatibility:

powershell
1# Use SFTP subsystem explicitly
2net use Z: "\\sshfs\user@host\path?ssh_command=sftp"

Monitoring and Management

Check Mount Status

powershell
1# View detailed information about mounted drives
2Get-PSDrive -PSProvider FileSystem | Where-Object {$_.DisplayRoot -like "*sshfs*"}
3
4# View network statistics
5net use Z:
6
7# Test connectivity
8Test-NetConnection -ComputerName host -Port 22

Unmounting

powershell
1# Graceful unmount
2net use Z: /delete
3
4# Force unmount if drive is busy
5net use Z: /delete /yes
6
7# Unmount all network drives
8net use * /delete /yes

Security Considerations

  1. SSH Key Management: Always use SSH keys with passphrases instead of password authentication
  2. Host Key Verification: Ensure the remote host's fingerprint is verified on first connection
  3. Network Security: Use VPN when accessing SSH servers over untrusted networks
  4. Credential Storage: SSHFS-Win uses Windows Credential Manager; review stored credentials regularly:
    powershell
    1cmdkey /list | Select-String "sshfs"

Integration with Windows Explorer

After mounting, the SSH folder appears in Windows Explorer like any other drive:

  • Quick Access: Pin frequently used SSH drives to Quick Access
  • Search: Windows Search indexes mounted drives (can be disabled for privacy)
  • File Operations: Drag-and-drop, copy-paste work seamlessly
  • Context Menu: Right-click operations are supported

Comparison with Alternatives

FeatureSSHFS-WinWinSCPMapped SMB
Mount as Drive✅ Yes❌ No✅ Yes
SSH Protocol✅ Yes✅ Yes❌ No
Windows Explorer Integration✅ Full⚠️ Partial✅ Full
Performance⚠️ Medium✅ High✅ High
Setup Complexity✅ Low⚠️ Medium⚠️ Medium
Cross-platform✅ Yes❌ Windows only⚠️ Limited

Additional Resources