Windows Powershell Screenshot

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:

  1. Generate a key pair:ssh-keygen Save it to the default location (C:\Users\<YourUser>\.ssh\id_rsa).
  2. Copy your public key to the remote server:ssh-copy-id username@remote_host (If ssh-copy-id isn’t available, manually copy the contents of id_rsa.pub into the remote server’s ~/.ssh/authorized_keys file.)
  3. Test your connection:ssh username@remote_host You should connect without entering a password.

đź§® Common PowerShell SSH Commands

CommandDescriptionExample
ssh user@hostConnect to a remote systemssh admin@192.168.1.10
scp file user@host:/pathCopy files to a remote systemscp report.txt admin@server:/tmp
sftp user@hostOpen an interactive file transfer sessionsftp admin@192.168.1.10
ssh-keygenGenerate SSH key pairsssh-keygen -t rsa -b 4096
ssh-agentManage SSH keys in memoryStart-Service ssh-agent
ssh-addAdd a private key to the SSH agentssh-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

FeatureBenefit
Native SSH supportNo need for third-party tools
Cross-platform compatibilityManage Windows, Linux, and macOS
Secure encryptionProtects data during remote sessions
Key-based authenticationIncreases security and convenience
Integration with PowerShell RemotingEnables 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.

Similar Posts