Windows Computer: Gaining SSH Access Outside Home Network Using PowerShell

Abstract: Enable OpenSSH on Windows via PowerShell, configure firewall rules, and set up router port forwarding for secure remote access.

Created: 2026-08-09 by

Accessing a Windows machine remotely via SSH from outside your local network requires enabling the built-in OpenSSH server, configuring port forwarding on your router, and ensuring proper firewall rules are in place. This guide outlines the PowerShell commands needed to activate the service and secure external access without relying on third-party software.

Enabling OpenSSH Server on Windows 10 and 11

Modern versions of Windows include OpenSSH capabilities as optional features rather than pre-installed services. To gain remote access, you must first install the server component. Unlike older server operating systems that used Install-WindowsFeature, Windows 10 and 11 use the Add-WindowsCapability cmdlet. This distinction is critical because using incorrect commands can lead to installation failures or non-functional services.

Open PowerShell with administrative privileges by right-clicking the Start menu icon and selecting "Terminal (Admin)" or "Windows PowerShell (Admin)." Execute the following command to install the OpenSSH Server:

Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0

Once the installation completes, verify that the feature was added successfully. You can check the status by running Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'. The output should show both the client and server capabilities with a state of "Installed." If the state remains "NotPresent," ensure your internet connection is active and retry the installation command.

Configuring the SSH Service and Firewall

After installation, the SSH service does not start automatically. You need to start the service and configure it to launch at boot time. Use the following commands to achieve this:

Start-Service sshd
Set-Service -Name sshd -StartupType 'Automatic'

By default, Windows Defender Firewall may block incoming connections on port 22. While some configurations allow traffic by default, explicitly creating an inbound rule ensures reliability. Run this command to add the necessary firewall exception:

New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22

If you have changed the default SSH port for security reasons, replace 22 with your custom port number in both the service startup configuration and the firewall rule. It is also advisable to modify the sshd_config file located at C:\ProgramData\ssh\sshd_config if you wish to restrict root login or change authentication methods, though the default settings are generally sufficient for basic access.

Windows Computer: Gaining SSH Access Outside Local Network Using PowerShell provides additional context on securing these initial steps against common vulnerabilities.

Setting Up Port Forwarding on Your Router

External access requires your home router to direct incoming traffic to your specific Windows machine. This process is known as port forwarding. You must first assign a static IP address to your Windows computer to prevent its local IP from changing after reboots. You can do this via the Network Adapter settings in Control Panel or by reserving the IP in your router's DHCP settings.

Navigate to your router's administration page, typically accessible via 192.168.1.1 or 192.168.0.1 in a web browser. Look for a section labeled "Port Forwarding," "Virtual Servers," or "NAT." Create a new rule with the following parameters:

  • Service Name: SSH
  • External Port: 22 (or your custom port)
  • Internal Port: 22
  • Internal IP Address: The static IP of your Windows PC
  • Protocol: TCP

Save the settings and restart the router if necessary. This step bridges the gap between the public internet and your private local network, allowing external requests to reach your SSH daemon.

Connecting from Outside the Network

To connect from an external location, you need the public IP address of your home network. Visit a site like whatismyipaddress.com from a device connected to the same Wi-Fi to find this address. Alternatively, if your ISP assigns dynamic IPs, consider setting up a Dynamic DNS (DDNS) service to map a domain name to your changing IP address.

From any remote machine, open a terminal and use the standard SSH syntax. Replace username with your Windows user account name and public_ip with your home network's public IP:

ssh username@public_ip

You will be prompted for your Windows password. If you encounter connection timeouts, verify that your router's port forwarding is active and that no other firewall software (such as third-party antivirus suites) is blocking the connection. For enhanced security, consider generating SSH keys and disabling password authentication in the sshd_config file, allowing only key-based logins.

How to configure powershell for OpenSSH instead of cmd explains how to integrate these tools seamlessly into your daily workflow.

Frequently Asked Questions

Why does my SSH connection time out even after port forwarding?

This is often caused by your ISP blocking port 22 or a secondary firewall on your router interfering with the rule. Try changing the external port to something unusual like 2222 in your router settings and update your SSH command to ssh -p 2222 user@ip. If it works, your ISP is likely filtering standard ports.

Can I use SSH on Windows Home edition?

Yes, Windows Home editions support the OpenSSH server just like Pro or Enterprise versions. The installation commands and configuration steps remain identical, provided you have administrative privileges to run PowerShell as an administrator.

Is it safe to expose my Windows PC directly to the internet via SSH?

Exposing SSH directly carries risks such as brute-force attacks. It is safer to use key-based authentication exclusively, disable password login, and consider using a reverse proxy or a tunneling service like Tailscale if you want to avoid opening router ports entirely.

What happens if my public IP address changes?

If your ISP uses dynamic IP addressing, your connection will break when the IP changes. To solve this, configure a Dynamic DNS (DDNS) service on your router or use a tool like Dynu to update a hostname automatically whenever your IP changes.

How do I reset the SSH server if it stops working?

If the service becomes unresponsive, restart it using PowerShell with Restart-Service sshd. If issues persist, check the event viewer under Applications and Services Logs > OpenSSH for detailed error messages regarding configuration syntax or permission errors.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More