WindowsPublished on May 29, 202612 min read

How to share a folder between a Windows VPS and a local PC (2026)

This guide shows how to share a folder between a Windows VPS and a local PC, then mount it on Windows, macOS or Linux as a network drive. It covers four methods, from the safest to the simplest: SMB over a VPN, SMB in an SSH tunnel, SFTP and WebDAV. The commands target Windows Server 2025, the system delivered on OuiHeberg Windows VPS. First connect to the VPS over Remote Desktop, as explained in Connect to a Windows VPS via RDP.

Why share a folder from a Windows VPS

  • Store and fetch backups, like on a remote NAS.

  • Read an app's logs without opening an RDP session.

  • Share files between colleagues through a common VPS.

  • Keep documents or media in one place for several computers.

  • Give a business app the network drive it expects, as a \\server\folder path.

Unlike a NAS at home, the VPS can be reached from anywhere and can run other services at the same time.


Never expose SMB to the Internet

SMB, the Windows sharing protocol, was not designed for the Internet. Its TCP port 445 is one of the favourite targets of mass attacks. Since 2017 it has been the way in for ransomware such as WannaCry and NotPetya.

If the VPS port 445 is open to the Internet, bots try passwords and known SMB flaws such as EternalBlue every day. A single unpatched flaw can give full administrator access, and ransomware then encrypts every exposed file.

Never open port 445 directly to the Internet. Run SMB through a VPN or an SSH tunnel, or use an encrypted protocol such as SFTP or WebDAV over HTTPS. All four methods in this guide follow this rule.


Choose a method

MethodSecuritySpeedSetupBest for
A. SMB over a WireGuard VPNVery highVery goodMediumPermanent network drive, the reference method
B. SMB in an SSH tunnelVery highAverageTrickierIf you already use SSH
C. SFTPVery highGoodSimpleOccasional transfers, the quickest to set up
D. WebDAV over HTTPSHighAverageMediumNetworks that block SSH and VPNs
Direct SMB on port 445DangerousVery goodSimpleNever do it

All methods work from Windows, macOS and Linux. For a network drive that behaves like on a local network, pick method A. For occasional file transfers, method C is enough.


Share over SMB through a WireGuard VPN

The VPS runs a WireGuard server. Your PC connects to the VPN and sees the VPS on a private address, here 10.0.0.1. The SMB share then opens as on a local network, without being visible from the Internet.

Install WireGuard on the VPS

Download WireGuard for Windows from wireguard.com and install it on the VPS. Then generate the server keys in PowerShell as administrator.

cd "C:\Program Files\WireGuard"
.\wg.exe genkey | Out-File -Encoding ascii server_private.key
Get-Content server_private.key | .\wg.exe pubkey | Out-File -Encoding ascii server_public.key

Create the file C:\WireGuard\wg0.conf with this content.

[Interface]
PrivateKey = <content of server_private.key>
ListenPort = 51820
Address = 10.0.0.1/24

[Peer]
PublicKey = <public key of the client PC>
AllowedIPs = 10.0.0.2/32

Install this tunnel as a Windows service so it starts with the VPS. You can also import it into the WireGuard app and activate it.

# Install the tunnel as a Windows service (starts with the server)
& "C:\Program Files\WireGuard\wireguard.exe" /installtunnelservice "C:\WireGuard\wg0.conf"

Open the WireGuard port

New-NetFirewallRule -DisplayName "WireGuard UDP 51820" `
    -Direction Inbound -Protocol UDP -LocalPort 51820 -Action Allow

The client area has no network firewall for VPS, so only the Windows Firewall matters. The guide How to open a port in Windows Firewall on a VPS covers rule management.

Restrict SMB to the VPN network

In the Windows Firewall, a block rule always wins over an allow rule, according to Microsoft's documentation. A rule blocking port 445 for everyone would therefore block the VPN too. Instead, allow SMB only from the VPN subnet and restrict the other rules that open this port.

# Make sure the firewall is on for all profiles
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True

# Allow SMB from the VPN subnet only
New-NetFirewallRule -DisplayName "SMB via VPN only" `
    -Direction Inbound -Protocol TCP -LocalPort 445 `
    -RemoteAddress 10.0.0.0/24 -Action Allow

# Restrict every other rule opening port 445 to the VPN
Get-NetFirewallPortFilter -Protocol TCP | Where-Object { $_.LocalPort -eq 445 } |
    Get-NetFirewallRule | Where-Object { $_.DisplayName -ne "SMB via VPN only" } |
    Set-NetFirewallRule -RemoteAddress 10.0.0.0/24

Install WireGuard on the PC

Install the WireGuard client for Windows, macOS or Linux, then create a tunnel with this configuration.

[Interface]
PrivateKey = <client private key>
Address = 10.0.0.2/24

[Peer]
PublicKey = <server public key>
Endpoint = <vps-public-ip>:51820
AllowedIPs = 10.0.0.0/24   # routes ONLY the VPN, not all your traffic
PersistentKeepalive = 25

Activate the tunnel, then check that the VPS answers.

ping 10.0.0.1

For a VPN server on a Linux VPS, follow How to install a WireGuard VPN server on a Linux VPS.

Open the share

In File Explorer on the PC, type this address in the address bar, then your Windows credentials for the VPS.

\\10.0.0.1\Share

The VPS port 445 stays closed to the Internet, invisible to scans. Creating the share on the VPS is covered below.


Share over SMB in an SSH tunnel

OpenSSH Server is installed by default on Windows Server 2025, according to Microsoft. You only need to start it and open its port.

# Already present on Windows Server 2025: the command then changes nothing
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Start-Service sshd
Set-Service -Name sshd -StartupType Automatic
New-NetFirewallRule -Name sshd -DisplayName "OpenSSH Server" `
    -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

From your PC, on Windows, macOS or Linux, open the tunnel. It forwards local port 4450 to port 445 of the VPS through SSH.

ssh -L 4450:127.0.0.1:445 YourAccount@<vps-ip>

On Windows 11 24H2 or later, the SMB client accepts a port other than 445, according to Microsoft. Mount the share like this.

# Windows 11 24H2 or later, command prompt run as administrator
net use Z: \\127.0.0.1\Share /TCPPORT:4450

Older Windows versions cannot mount a share on another port, so use method A instead. On Linux or macOS, mount the share with this command.

sudo mount -t cifs //127.0.0.1/Share /mnt/vps -o port=4450,username=YourAccount

Transfer files over SFTP

SFTP is the file transfer built into OpenSSH. It encrypts everything, accepts SSH keys and works with WinSCP, FileZilla, Cyberduck, Finder or the Linux file manager. Enable OpenSSH on the VPS with the same block as for method B. SFTP is active as soon as the service runs.

Restrict SSH to your addresses

Windows Server 2025 may already have its own rule for port 22. This command restricts every rule that opens this port.

# Restrict port 22 to your addresses, whichever rule opens it
Get-NetFirewallPortFilter -Protocol TCP | Where-Object { $_.LocalPort -eq 22 } |
    Get-NetFirewallRule | Set-NetFirewallRule -RemoteAddress "203.0.113.42"

Connect from the PC

  • On Windows, install WinSCP, free, with drag-and-drop.

  • On macOS, in Finder, press Cmd+K and enter sftp://<vps-ip>.

  • On Linux, in the file manager, connect to a server with sftp://<vps-ip>.

  • On every system, FileZilla is free.

Mount SFTP as a Windows drive

To see the VPS folder as a Z: drive, install SFTP Net Drive or use rclone mount, which is open source. Set the connection to sftp://<vps-ip> and pick the drive letter. All your apps then see the folder as a local disk.

SFTP encrypts end to end, accepts SSH key authentication and opens no SMB port. A single port is enough, the SSH one.


Share over WebDAV with HTTPS

WebDAV adds file reading and writing to HTTP. It uses port 443, open almost everywhere, even in hotels or companies that block SSH and VPNs. Install IIS with WebDAV and basic authentication.

Install-WindowsFeature -Name Web-Server, Web-WebDAV-Publishing, Web-Basic-Auth `
    -IncludeManagementTools

In IIS Manager, select the site, enable Basic Authentication, then enable WebDAV in WebDAV Authoring Rules. Add a rule that gives read and write access to the allowed users. Finally install a certificate and serve the site over HTTPS only, as explained in Install Let's Encrypt on IIS.

  • On Windows, right-click This PC, then Map network drive, and enter https://your-domain.com.

  • On macOS, in Finder, press Cmd+K and enter the same address.

  • On Linux, install the davfs2 package, then mount the folder.

sudo mount -t davfs https://your-domain.com /mnt/dav

WebDAV is slower than SMB or SFTP, and its file locking is less reliable. Do not use it for databases or files edited by several people at once.


Create the SMB share on the VPS

Methods A and B need an SMB share on the VPS. You can create it in the interface or with PowerShell.

In the interface

  1. Create the folder to share, for example C:\Share.

  2. Right-click the folder, then Properties, Sharing tab, and click Advanced Sharing.

  3. Tick Share this folder.

  4. Click Permissions, add your Windows user and tick the rights you need.

  5. In Caching, turn off offline caching if you want changes to show at once.

With PowerShell

# Create the folder
New-Item -Path "C:\Share" -ItemType Directory -Force

# Create the SMB share
New-SmbShare -Name "Share" `
    -Path "C:\Share" `
    -FullAccess "YourAccount" `
    -Description "User share"

# Check
Get-SmbShare -Name "Share" | Format-List

A share created with New-SmbShare is available at once and survives restarts.

# Hidden share (the name does not appear in the share list)
New-SmbShare -Name "Share$" -Path "C:\Share" -FullAccess "YourAccount"

# Read-only share ("Everyone" on an English Windows)
New-SmbShare -Name "ShareRO" -Path "C:\Share" -ReadAccess "Everyone"

# Encrypt this share
Set-SmbShare -Name "Share" -EncryptData $true -Force

Encrypt SMB and disable SMB1

Set-SmbServerConfiguration -EncryptData $true -Force
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
Set-SmbServerConfiguration -EnableSMB2Protocol $true -Force

Disabling SMB1 protects against EternalBlue, the flaw used by WannaCry. No recent client needs it. SMB encryption protects the content even inside the VPN.

Between two OuiHeberg VPS

To share a folder between two VPS in the same location, the private network of the client area avoids going through the Internet. You enable it on the Network and IP tab of each VPS. The guide How to connect two VPS over a private network explains the setup. Then restrict SMB to the private address of the other VPS.

Network and IP tab of a VPS with the Private network card not enabled and its three steps


Mount the share on your PC

On Windows 10 or 11

  1. In File Explorer, right-click This PC, then Map network drive.

  2. Pick the letter Z: and enter the folder \\10.0.0.1\Share, the VPS address in the VPN.

  3. Tick Reconnect at sign-in and Connect using different credentials.

  4. Enter the Windows account of the VPS.

In PowerShell, the New-PSDrive command does the same.

# Temporary drive
New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\10.0.0.1\Share" -Credential (Get-Credential)

# Drive kept after a restart
New-PSDrive -Name "Z" -PSProvider FileSystem -Root "\\10.0.0.1\Share" `
    -Credential (Get-Credential) -Persist

The net use command works too.

net use Z: \\10.0.0.1\Share /user:YourAccount YourPassword /persistent:yes

On macOS

  1. In Finder, open Go › Connect to Server (Cmd+K).

  2. Enter smb://10.0.0.1/Share, then your credentials.

The share shows up in the Finder sidebar. To mount it at every login, add it in System Settings › General › Login Items.

On Linux (Ubuntu, Debian)

Install cifs-utils, create the mount point, then mount the share.

sudo apt update
sudo apt install cifs-utils
sudo mkdir /mnt/vps-partage
sudo mount -t cifs //10.0.0.1/Share /mnt/vps-partage \
    -o username=YourAccount,password=YourPassword,uid=$(id -u),gid=$(id -g)

To mount it automatically at boot, first store the credentials in a protected file.

sudo bash -c 'cat > /root/.smbcredentials << EOF
username=YourAccount
password=YourPassword
EOF'
sudo chmod 600 /root/.smbcredentials

Then add this line to /etc/fstab and test without rebooting with sudo mount -a.

//10.0.0.1/Share  /mnt/vps-partage  cifs  credentials=/root/.smbcredentials,uid=1000,gid=1000,iocharset=utf8,_netdev  0  0

Understand NTFS and share permissions

Two layers of permissions apply to an SMB share. Share permissions only apply to network access. NTFS permissions always apply, locally and over the network. The effective permission is the more restrictive of the two.

Share permissionNTFS permissionResult
ReadModifyRead
ChangeReadRead
Full ControlModifyModify
Full ControlFull controlFull control

Good practice is to give full control to authenticated users on the share, then fine-tune NTFS permissions per account or group. That is where security really happens.

# NTFS permissions in PowerShell
$acl = Get-Acl "C:\Share"
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule(
    "YourAccount", "Modify", "ContainerInherit,ObjectInherit", "None", "Allow"
)
$acl.SetAccessRule($rule)
Set-Acl "C:\Share" $acl

Troubleshoot

"Access denied" despite the right permissions

Share and NTFS permissions conflict, or Windows keeps old credentials in its cache. Clear them.

net use * /delete /y    # remove all mapped drives
cmdkey /list            # list stored credentials
cmdkey /delete:<name>   # delete an outdated credential

"The network path was not found"

The PC cannot reach the VPS. Ping the VPS address in the VPN. If ping works but SMB does not, check that port 445 is open for the VPN subnet and that the service runs with Get-Service LanmanServer.

The share is very slow

  • The VPN MTU does not fit: add MTU = 1280 to the WireGuard configuration.

  • The PC's antivirus scans all SMB traffic.

  • SMB1 is still enabled: disable it with Set-SmbServerConfiguration -EnableSMB1Protocol $false.

  • SMB encryption adds to the VPN's own: the VPN already encrypts, so you can turn off EncryptData.

The share disappears after a restart

Get-SmbShare -Name "Share"
# Missing: the share no longer exists, create it again with New-SmbShare

A share created with New-SmbShare is persistent. If it disappears, look in Task Scheduler for a script that deletes or recreates it at each startup.

STATUS_USER_SESSION_DELETED error (0xC0000203)

The SMB session was lost, after a VPN drop for example. On the PC, extend the SMB session timeout.

# On the client: extend the SMB session timeout
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" `
    -Name "SessTimeout" -Value 600

"The account is locked out"

Too many failed attempts triggered the lockout policy, described in Block RDP brute-force attacks on a Windows VPS. Wait until the lockout ends, or reactivate the account on the VPS.

net user YourAccount /active:yes

Need help?

Open a ticket from Tickets › Open a Ticket, or from the Contact support tile at the bottom of the VPS page. In the Related Service field, pick the VPS so the team saves time. You can also ask your question on the OuiHeberg Discord.

Was this article helpful?

438 views
Share this article
Need a Windows VPS?

Windows Server 2025 with the license included, Remote Desktop access and management from the client area.

View plans →

Related Articles