GitHub ↗

PowerShell version

For Windows users who live in PowerShell. No Git Bash needed. Same safety, same alias, same ssh vps2 afterwards.

Invoke-WebRequest -Uri https://raw.githubusercontent.com/mymyanmarland/vps-connect/main/connect-vps.ps1 -OutFile connect-vps.ps1
curl.exe -O https://raw.githubusercontent.com/mymyanmarland/vps-connect/main/connect-vps.ps1
If PowerShell blocks the script, do not change your system policy first. Either unblock this one file, or run it once without changing any policy:
Unblock-File .\connect-vps.ps1
.\connect-vps.ps1 -Name vps2 -Host <VPS-IP>
powershell -ExecutionPolicy Bypass -File .\connect-vps.ps1 -Name vps2 -Host <VPS-IP>
ssh vps2

Alternative, if you prefer a policy change: Set-ExecutionPolicy -Scope CurrentUser RemoteSigned — a file downloaded with a browser may still need Unblock-File even under RemoteSigned. A file downloaded with Invoke-WebRequest usually does not carry that mark.

1. Open PowerShell (not CMD) in the folder where you downloaded the script.
2. Run it.
.\connect-vps.ps1 -Name vps2 -Host <VPS-IP> — or just .\connect-vps.ps1 and answer the two prompts.
3. First time only: type the VPS password in your own PowerShell window, at that prompt.
It is never stored or printed by the script.
4. Done. Connect any time.
ssh vps2 — in PowerShell, or in any terminal that reads the same %USERPROFILE%\.ssh\config file.

How it differs from the Bash version

Try the dry run first: .\connect-vps.ps1 -DryRun -Name vps2 -Host <VPS-IP> — it changes nothing and contacts no VPS.

Requirements: Windows 10/11 built-in OpenSSH client (ssh, ssh-keygen). If ssh is missing: Settings > Apps > Optional features > OpenSSH Client, or as Administrator: Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0