Install OpenSSH on Windows VM (within Google Compute Engine)

26 Nov 2016

Here's the powershell script to install OpenSSH on Windows:

# Create helpers. $shell = new-object -com shell.application Function unzip($fileName, $folder = "c:\") { $zip = $shell.NameSpace($fileName) foreach($item in $zip.items()) { $shell.Namespace($folder).copyhere($item) } } $webClient = New-Object System.Net.WebClient $fileName = "c:\" $webclient.DownloadFile("", $fileName) unzip $fileName 'c:\Program Files' # OpenSSH needs to be in c:\Program Files\OpenSSH because its default # sshd_config expects that folder. move "c:\Program Files\OpenSSH-Win64" "c:\Program Files\OpenSSH" Invoke-Expression -Command "& 'c:\Program Files\OpenSSH\install-sshd.ps1'" cmd /s /c "cd /d "c:\Program Files\OpenSSH" && "C:\Program Files\OpenSSH\ssh-keygen.exe" -A" netsh advfirewall firewall add rule name="SSH Port" dir=in action=allow protocol=TCP localport=22 cmd /c sc config "sshd" start= auto cmd /c sc failure "sshd" actions= restart/60000/restart/60000/restart/60000 reset= 86400 net start sshd

Then, you can simply SSH into the windows VM using your usual username and password. (I haven't figured out how to setup a private-public key yet.)

Give it a kudos