Secure Shell (SSH) is a powerful protocol that allows you to securely connect to remote systems and servers. With the integration of SSH directly into Windows PowerShell, you can now manage Linux servers, network devices, and other remote systems without needing third-party tools like PuTTY.
This guide explains how to set up, configure, and use SSH in Windows PowerShell, along with helpful commands and troubleshooting tips.
đź§© What Is SSH in PowerShell?
SSH (Secure Shell) is a network protocol that provides an encrypted channel for remote communication. PowerShell’s built-in SSH support allows you to:
- Connect to remote systems securely
- Run commands on remote machines
- Transfer files over encrypted connections
- Manage cross-platform environments (Windows ↔ Linux ↔ macOS)
Starting from Windows 10 (version 1809) and Windows Server 2019, Microsoft includes an OpenSSH client and server by default, making SSH available natively within PowerShell.
⚙️ How to Check If SSH Is Installed
Open PowerShell and run:
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
If it’s installed, you’ll see something like:
Name : OpenSSH.Client~~~~0.0.1.0
State : Installed
If not, install it using:
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
You can also install the OpenSSH Server if you want to accept inbound SSH connections:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
🔑 Connecting to a Remote Server via SSH
Once installed, you can connect to a remote system using the ssh
command:
ssh username@remote_host
Example:
ssh admin@192.168.1.100
You’ll be prompted for a password unless you’ve configured SSH key authentication.
🗝️ Setting Up SSH Key Authentication
Using SSH keys is more secure than passwords. Here’s how to set it up:
- Generate a key pair:
ssh-keygen
Save it to the default location (C:\Users\<YourUser>\.ssh\id_rsa
). - Copy your public key to the remote server:
ssh-copy-id username@remote_host
(Ifssh-copy-id
isn’t available, manually copy the contents ofid_rsa.pub
into the remote server’s~/.ssh/authorized_keys
file.) - Test your connection:
ssh username@remote_host
You should connect without entering a password.
đź§® Common PowerShell SSH Commands
Command | Description | Example |
---|---|---|
ssh user@host | Connect to a remote system | ssh admin@192.168.1.10 |
scp file user@host:/path | Copy files to a remote system | scp report.txt admin@server:/tmp |
sftp user@host | Open an interactive file transfer session | sftp admin@192.168.1.10 |
ssh-keygen | Generate SSH key pairs | ssh-keygen -t rsa -b 4096 |
ssh-agent | Manage SSH keys in memory | Start-Service ssh-agent |
ssh-add | Add a private key to the SSH agent | ssh-add ~\.ssh\id_rsa |
đź§° Troubleshooting SSH in PowerShell
1. SSH command not found?
Make sure the OpenSSH client is installed and added to your system PATH.
2. Permission denied (publickey)?
Ensure your public key is correctly placed in the remote server’s ~/.ssh/authorized_keys
file and has proper permissions.
3. Connection timeout or refused?
Verify that the remote server’s SSH service is running and accessible on port 22.
4. Key not loading automatically?
Start the SSH agent and add your key manually:
Start-Service ssh-agent
ssh-add ~\.ssh\id_rsa
🔄 Using PowerShell Remoting with SSH
PowerShell 7+ supports PowerShell Remoting over SSH, allowing you to run PowerShell commands on remote systems securely.
Example:
Enter-PSSession -HostName server01 -UserName admin -SSHTransport
To run a single command remotely:
Invoke-Command -HostName server01 -UserName admin -SSHTransport -ScriptBlock { Get-Process }
đź§ Summary
Feature | Benefit |
---|---|
Native SSH support | No need for third-party tools |
Cross-platform compatibility | Manage Windows, Linux, and macOS |
Secure encryption | Protects data during remote sessions |
Key-based authentication | Increases security and convenience |
Integration with PowerShell Remoting | Enables advanced automation |
âś… Conclusion
Using SSH in Windows PowerShell transforms your system into a powerful cross-platform management tool. Whether you’re connecting to Linux servers, transferring files securely, or automating remote tasks, SSH gives you flexibility and security — all within the PowerShell environment.