Created
July 29, 2022 09:37
-
-
Save SARDONYX-sard/01945825c75377432ba854600b62d471 to your computer and use it in GitHub Desktop.
How to connect to Windows via ssh using OpenSSH server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# How to automation ssdh? | |
# | |
# 1. Execute `compmgmt.msc` on powershell | |
# 2. Service & application -> duble click service | |
# 3. Find `OpenSSH SSH Server` | |
# 4. Select `automation` of `A kind of startup` item | |
# Are you root?(need `sudo command`. use `winget install gsudo) | |
if (-not ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(` | |
[Security.Principal.WindowsBuiltInRole] "Administrator")) { | |
Invoke-Expression "sudo $PsCommandPath $(if ($force) {"-force"})" | |
Write-Error "Need Administrator" | |
exit $? | |
} | |
Start-Service sshd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using VS studio 2022 PowerShell for default shell.