DEV Community

Nate
Nate

Posted on Originally published at shadeterm.com

Using OpenSSH from PowerShell: A Practical SSH Workflow

PowerShell can run the standard OpenSSH client, so connecting from Windows to a Linux server usually doesn't require PuTTY or an extra PowerShell module. The key distinction is that ssh gives you the remote machine's shell; it is not the same thing as PowerShell Remoting over SSH.

Check the client and make a first connection

Open PowerShell or Windows Terminal and check whether the client is available:

Get-Command ssh
ssh -V
Enter fullscreen mode Exit fullscreen mode

If ssh is missing, open PowerShell as Administrator and install the Windows OpenSSH Client capability:

Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH.Client*'
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Enter fullscreen mode Exit fullscreen mode

You need the Client to connect out to another computer. You don't need to install the OpenSSH Server feature on your PC just to connect to a remote server.

Once the client is available, connect using the account name on the remote machine:

ssh deploy@server.example.com
Enter fullscreen mode Exit fullscreen mode

Replace the example username and hostname with your own. On the first connection, OpenSSH asks you to verify the server's host-key fingerprint. Compare it with a trusted provider console or ask the server administrator before accepting it. After a verified connection, the host key is recorded in ~/.ssh/known_hosts.

A later warning that the host identification has changed is worth investigating. Don't bypass it by disabling host-key checking without understanding why the key changed.

Add a port or choose a private key

SSH uses port 22 by default. If your server listens on a different port, specify it with lowercase -p:

ssh -p 2222 deploy@server.example.com
Enter fullscreen mode Exit fullscreen mode

To authenticate with a particular private key, use -i:

$key = Join-Path $HOME '.ssh\id_ed25519'
ssh -i $key deploy@server.example.com
Enter fullscreen mode Exit fullscreen mode

The matching public key must already be authorized for that remote account. If you need to create a key pair, choose a new filename so you don't accidentally overwrite an existing key:

New-Item -ItemType Directory -Force -Path "$HOME\.ssh" | Out-Null
ssh-keygen -t ed25519 -f "$HOME\.ssh\id_ed25519_powershell"
Enter fullscreen mode Exit fullscreen mode

Give the server administrator the .pub file, not the private key. Keep the private key protected, and retain its passphrase if you set one. If the server can be reached but rejects the key, the public-key authentication troubleshooting guide covers common causes.

Save connection details in SSH config

If you regularly connect to the same machine, an SSH host alias saves you from retyping its hostname, port, username, and key path. The per-user config file on Windows is normally $HOME\.ssh\config, with no .txt extension.

Create the directory and open the file if needed:

$sshDir = Join-Path $HOME '.ssh'
New-Item -ItemType Directory -Force -Path $sshDir | Out-Null
$config = Join-Path $sshDir 'config'
if (-not (Test-Path $config)) { New-Item -ItemType File -Path $config | Out-Null }
notepad $config
Enter fullscreen mode Exit fullscreen mode

Add an entry, replacing the example values:

Host my-vps
    HostName server.example.com
    User deploy
    Port 2222
    IdentityFile ~/.ssh/id_ed25519
Enter fullscreen mode Exit fullscreen mode

You can inspect the settings SSH resolves for an alias without connecting to the server:

ssh -G my-vps | Select-String -Pattern '^(hostname|user|port|identityfile) '
Enter fullscreen mode Exit fullscreen mode

When the values look right, connect with the shorter name:

ssh my-vps
Enter fullscreen mode Exit fullscreen mode

Run a command or transfer a file

You can run a command on the remote host and receive its output without opening an interactive shell:

ssh my-vps 'uptime'
ssh my-vps 'whoami'
Enter fullscreen mode Exit fullscreen mode

PowerShell parses local arguments before passing them to OpenSSH. When a remote Linux shell should expand a variable such as $HOME, quoting needs care: a single-quoted PowerShell argument can keep PowerShell from expanding it first.

For file transfers, OpenSSH commonly includes scp and sftp alongside ssh:

scp .\report.txt my-vps:/tmp/report.txt
sftp my-vps
Enter fullscreen mode Exit fullscreen mode

One easy-to-miss difference: ssh uses lowercase -p to select a port, while scp uses uppercase -P.

Diagnose connection failures in layers

Start by checking the client, then test whether the destination port is reachable, and finally ask SSH for verbose connection details:

Get-Command ssh
Test-NetConnection server.example.com -Port 22
ssh -v deploy@server.example.com
Enter fullscreen mode Exit fullscreen mode

TcpTestSucceeded : True means the TCP port is reachable; it doesn't confirm that your username, password, key, or host identity is valid. A connection refusal points to a different problem than a rejected key: the SSH connection-refused checklist walks through listeners, ports, and firewall checks.

Common clues include:

  • ssh is not recognized: The OpenSSH Client may be missing or unavailable on PATH.
  • Could not resolve hostname: Check spelling, DNS, and any alias in your SSH config.
  • Connection timed out: Check routing, firewall rules, and whether you're using the right address and port.
  • Permission denied (publickey): Confirm the remote username, selected private key, and that its public key is authorized.
  • Host identification has changed: Verify the server's identity before changing known_hosts.

Verbose output can include usernames, addresses, and other useful diagnostic details. Review it before posting it publicly.

Don't confuse SSH with PowerShell Remoting

The command ssh user@host starts the remote system's normal shell, such as Bash on Linux. Enter-PSSession -HostName ... is a separate feature: it uses SSH as a transport for a PowerShell session and requires PowerShell 6 or later plus the appropriate PowerShell subsystem configuration on the remote host. It isn't a drop-in way to open a PowerShell session on any SSH server.

For ordinary server administration from Windows, the OpenSSH client in PowerShell is often enough: verify the client, verify the host key, connect, and add config aliases as your workflow grows.

I originally published a more detailed version of this guide on the ShadeTerm blog.

I'm also building ShadeTerm — an SSH client where every server gets its own workspace for terminals, SFTP, code, and databases.

Top comments (0)