How to Securely Setup Windows Filesharing Over SSH

Need to access your home or office files remotely from another location? Exposing standard Windows file sharing protocols directly to the open internet is extremely dangerous and can leave your network vulnerable to ransomware. You must setup Windows filesharing over SSH to protect your private data from unauthorized access while maintaining seamless file transfers.

This method creates an encrypted, secure tunnel for your Server Message Block (SMB) traffic. By routing your file requests through this tunnel, your data remains invisible to internet service providers and malicious actors. We will walk through the exact process to configure your host server and client machines safely and correctly.

Quick Facts: Project Overview

CategoryDetails
Time Required30 – 45 Minutes
Difficulty LevelAdvanced / IT Pro
Tools NeededWindows 10/11, Administrator Access, OpenSSH, PuTTY (Optional)
Core ConceptTCP Port Forwarding (Port 445)

Why Standard Windows File Sharing Fails Over the Internet

Windows uses the SMB protocol to share files and folders across a network. Natively, this protocol operates on TCP port 445. While SMB is highly efficient for local area networks (LANs), it lacks the robust security required for wide area networks (WANs) or the public internet.

Historically, exposing port 445 to the web has led to massive cybersecurity incidents, including the infamous WannaCry ransomware attacks. Internet Service Providers (ISPs) often block port 445 entirely to prevent malware propagation.

By utilizing a Secure Shell (SSH) tunnel, you bypass ISP restrictions. You encapsulate the vulnerable SMB traffic inside a heavily encrypted SSH connection running on port 22. This gives you the speed and convenience of network drives with the security of enterprise-grade encryption.

Comparison: Direct SMB vs. VPN vs. SSH Tunnel

To understand why this method is highly effective, review the functional differences between remote access configurations.

Access MethodSecurity LevelSetup ComplexityBest Use Case
Direct SMB (Port 445)Zero (Dangerous)Very LowLocal Home/Office Networks Only
Full Hardware VPNVery HighHighConnecting entire remote networks
SMB over SSH TunnelHighMediumSingle-user remote file access

Step 1: Prepare the Host Machine (Target Computer)

The host machine is the computer that physically holds the files you want to access. You need to enable file sharing and install an SSH server on this computer.

Enable Windows File Sharing:

  1. Open your Windows Settings and navigate to Network & internet.
  2. Go to Advanced network settings and open Advanced sharing settings.
  3. Turn on Network discovery and File and printer sharing.
  4. Right-click the specific folder you want to share, select Properties, and go to the Sharing tab.
  5. Click Advanced Sharing, check the box for Share this folder, and adjust the Permissions to allow your user account to read or write files.

Install the OpenSSH Server:

Windows 10 and 11 come with a built-in OpenSSH server, but it is not installed by default.

  1. Go to Settings > Apps > Optional features.
  2. Click View features (or Add a feature).
  3. Search for OpenSSH Server in the list.
  4. Select it, click Next, and then click Install. Wait for the installation bar to finish.

Start the SSH Service:

You must ensure the SSH service runs automatically whenever the computer boots up.

  1. Press the Windows Key + R, type services.msc, and press Enter.
  2. Scroll down the list until you find OpenSSH SSH Server.
  3. Right-click it and select Properties.
  4. Change the Startup type to Automatic.
  5. Click Start to run the service immediately, then click Apply and OK.

Step 2: The Port 445 Binding Problem on the Client Machine

Now we move to your local machine (the laptop or computer you are traveling with). Setting up an SSH tunnel requires forwarding local network traffic to the remote host. However, Windows presents a unique challenge here.

Windows natively binds its own SMB service to port 445 on the 0.0.0.0 address (meaning all network adapters). Because your local computer is already using port 445, your SSH client cannot open a listening port on localhost:445 to create the tunnel.

Attempting to forward port 445 locally will result in a “bind: Address already in use” error. To bypass this hardcoded Windows behavior without breaking your local file sharing, you must create a virtual loopback adapter.

Step 3: Install the Microsoft KM-TEST Loopback Adapter

The loopback adapter acts as a fake network card. We will assign it a dedicated IP address. This allows us to bind port 445 specifically to that new IP address, leaving the rest of your local computer functioning normally.

  1. Press the Windows Key + R, type hdwwiz.exe, and press Enter to open the Add Hardware Wizard.
  2. Click Next, then select Install the hardware that I manually select from a list (Advanced).
  3. Click Next, scroll down, and select Network adapters. Click Next.
  4. In the left column (Manufacturer), select Microsoft.
  5. In the right column (Model), select Microsoft KM-TEST Loopback Adapter.
  6. Click Next twice to install the virtual adapter, then click Finish.
Illustration of installing a virtual loopback adapter on a Windows laptop

Step 4: Configure the Loopback Adapter IP Address

Now that the virtual network card is installed, we need to assign it an isolated, non-routable IP address.

  1. Press the Windows Key + R, type ncpa.cpl, and hit Enter to open Network Connections.
  2. Locate the newly created connection. It will typically be named “Ethernet 2” or “Ethernet 3” and say “Microsoft KM-TEST Loopback Adapter” underneath.
  3. Right-click this new adapter and select Properties.
  4. Uncheck Client for Microsoft Networks and File and Printer Sharing for Microsoft Networks. (This step is mandatory. Unchecking these frees up port 445 specifically on this adapter).
  5. Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
  6. Select Use the following IP address.
  7. Enter 10.255.255.1 for the IP address. Click in the Subnet mask box, and it will auto-fill with 255.0.0.0.
  8. Leave the Default Gateway and DNS servers completely blank.
  9. Click Advanced, go to the WINS tab, and select Disable NetBIOS over TCP/IP. Click OK on all boxes to save.

Step 5: Establish the SSH Tunnel

Your client machine is now prepped. We can finally create the secure tunnel that routes our fake loopback IP directly to the remote server. You can do this using the native Windows Command Prompt or a graphical tool like PuTTY.

Method A: Using Windows Command Prompt (OpenSSH)

  1. Open Command Prompt or PowerShell on your local machine.
  2. You will use the following command structure: ssh -L [Local_IP]:445:[Remote_LAN_IP]:445 [Username]@[Public_IP_of_Server]
  3. For example, if your loopback adapter is 10.255.255.1, your target server’s local IP is 192.168.1.50, your Windows username is John, and your home internet’s public IP is 203.0.113.5, the command looks like this:

ssh -L 10.255.255.1:445:192.168.1.50:445 John@203.0.113.5

  1. Press Enter. If this is your first time connecting, type yes to accept the RSA fingerprint.
  2. Enter your Windows password for the remote machine. The terminal will log you in, and the tunnel is now active in the background. Do not close this terminal window.

Method B: Using PuTTY (Graphical Interface)

If you prefer saving your sessions, PuTTY is a fantastic free SSH client.

  1. Open PuTTY. In the Host Name (or IP address) box, enter your remote server’s public IP address.
  2. In the left-hand category tree, expand Connection, expand SSH, and click on Tunnels.
  3. In the Source port box, type 10.255.255.1:445.
  4. In the Destination box, type the remote server’s local LAN IP address followed by the port, like this: 192.168.1.50:445.
  5. Ensure the radio buttons below are set to Local and Auto.
  6. Click the Add button. You should see the route appear in the forwarded ports box.
  7. Go back to the Session category at the top left, type a name in the Saved Sessions box, and click Save.
  8. Click Open to connect, and enter your login credentials when prompted.

Step 6: Access the Shared Folders

With the SSH tunnel active, your local computer now believes the remote server is physically attached to the virtual loopback adapter.

  1. Open File Explorer on your local client machine.
  2. Click on the address bar at the very top.
  3. Type the IP address of your loopback adapter with a double backslash: \\10.255.255.1 and press Enter.
  4. Windows will prompt you for network credentials. Enter the username and password of the remote host machine.
  5. Check the Remember my credentials box so you do not have to type it every time.
  6. Your remote shared folders will now appear. You can browse, drag, drop, and edit files as if you were sitting right in front of the host computer.
Creating an encrypted SSH tunnel to securely access remote folders

To make things easier for the future, you can right-click any of these folders and select Map network drive. Assign it a letter (like Z:), and it will automatically appear in “This PC” whenever your SSH tunnel is active.

Advanced Troubleshooting Guide

Network configurations can sometimes be stubborn. If you follow the steps and cannot access your files, consult this table of common issues and their immediate fixes.

Error Message / SymptomRoot CauseSolution
“bind: Address already in use”Local Windows is blocking port 445.You forgot to disable “File and Printer Sharing” on the loopback adapter properties.
“Network path not found” (Error 0x80070035)Tunnel is not reaching the target.Ensure the OpenSSH Server service is running on the host. Check the host’s Windows Firewall rules.
Connection Refused in TerminalYour router is blocking external SSH.Log into your home router and setup “Port Forwarding” for external port 22 to the internal IP of the host machine.
Files are loading very slowlyOverhead from heavy encryption.SSH tunneling is CPU intensive. Use wired connections where possible, or use a lighter cipher in PuTTY settings.

Firewall Configuration Reminder

For external access to work, your home or office router must know where to send incoming SSH traffic. You must access your router’s administrative dashboard and forward TCP Port 22 to the static internal IP address of your host machine.

Furthermore, ensure that the Windows Defender Firewall on the host machine has an inbound rule allowing traffic over Port 22. The OpenSSH installation usually handles this automatically, but checking it manually prevents connection headaches.

Elevating Security with SSH Keys

While logging in with your Windows password works, it leaves your server exposed to brute-force password guessing attacks. For maximum security, you should disable password authentication entirely and switch to SSH Key-Based Authentication.

This involves generating a cryptographic public/private key pair on your local machine. You place the public key on your server and keep the private key on your local device. The server will only accept connections from a device holding the matching private key, making unauthorized access mathematically impossible.

If you found this guide helpful, share it with your IT team or drop a comment below with your specific setup questions!

Frequently Asked Questions (FAQs)

Can I use port 445 directly without a loopback adapter?

Technically yes, but it requires disabling the native “Server” service on your Windows client machine via the registry. Doing this will completely break your ability to share files locally from your client computer. The loopback adapter method is much safer and preserves local functionality.

Is SSH tunneling faster than a VPN for file sharing?

Generally, an SSH tunnel has lower overhead than a full-system VPN, making it slightly faster for single-application data transfers like SMB. However, performance ultimately depends on your upload speed at the host location and the processing power of the machines handling the encryption.

Why does my connection drop unexpectedly?

SSH connections can timeout if they remain idle for too long. In PuTTY, you can fix this by going to the “Connection” tab and setting the “Seconds between keepalives” to 60. This sends a tiny packet every minute to keep the tunnel awake.

Does this method work on both Windows 10 and Windows 11?

Yes. The underlying architecture for OpenSSH, the loopback adapter, and SMB file sharing is identical across both Windows 10 and Windows 11. The step-by-step process remains exactly the same.

Leave a Comment