Last active 1615609058

A script that should configure a given windows machine to have openssh running at least. opens vim to paste in authorized keys, installs scoop as well

Alyssa Smith revised this gist 1615645058. Go to revision

1 file changed, 1 insertion

win-remote-ssh.ps1

@@ -9,6 +9,7 @@ iwr https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.1.0.0p1-Bet
9 9 expand-archive -path "C:\Program Files\OpenSSH-Win64.zip" -destinationpath "C:\Program Files"
10 10 move-item "C:\Program Files\OpenSSH-Win64" "C:\Program Files\OpenSSH"
11 11 powershell.exe -ExecutionPolicy Bypass -File "C:\Program Files\OpenSSH\install-sshd.ps1"
12 + add-content -path "C:\programdata\ssh\sshd_config" -value "PasswordAuthentication no"
12 13 New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "C:\Program Files\OpenSSH\sshd.exe"
13 14 set-service sshd -StartupType automatic
14 15 start-service sshd

Alyssa Smith revised this gist 1615644906. Go to revision

1 file changed, 23 insertions

win-remote-ssh.ps1(file created)

@@ -0,0 +1,23 @@
1 + Set-ExecutionPolicy RemoteSigned
2 + New-Item -path $profile -type file -force
3 + Add-Content -path $profile -value '[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"'
4 + & $profile
5 + iwr -useb get.scoop.sh | iex
6 + scoop install git
7 + scoop update
8 + iwr https://github.com/PowerShell/Win32-OpenSSH/releases/download/v8.1.0.0p1-Beta/OpenSSH-Win64.zip -outfile "C:\Program Files\OpenSSH-Win64.zip"
9 + expand-archive -path "C:\Program Files\OpenSSH-Win64.zip" -destinationpath "C:\Program Files"
10 + move-item "C:\Program Files\OpenSSH-Win64" "C:\Program Files\OpenSSH"
11 + powershell.exe -ExecutionPolicy Bypass -File "C:\Program Files\OpenSSH\install-sshd.ps1"
12 + New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH SSH Server' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 -Program "C:\Program Files\OpenSSH\sshd.exe"
13 + set-service sshd -StartupType automatic
14 + start-service sshd
15 + scoop install vim
16 + vim C:\ProgramData\ssh\administrators_authorized_keys
17 + $acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys
18 + $acl.SetAccessRuleProtection($true, $false)
19 + $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow")
20 + $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow")
21 + $acl.SetAccessRule($administratorsRule)
22 + $acl.SetAccessRule($systemRule)
23 + $acl | Set-Acl
Newer Older