Alyssa Smith revised this gist . Go to revision
2 files changed, 46 insertions, 4 deletions
vultrwin.sh(file created)
| @@ -0,0 +1,40 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | domain="alyssasmith.id.au" | |
| 3 | + | if [ -z "$1" ]; then | |
| 4 | + | region="syd" | |
| 5 | + | else | |
| 6 | + | region="$1" | |
| 7 | + | fi | |
| 8 | + | if [ -z "$2" ]; then | |
| 9 | + | size="vc2-4c-8gb" | |
| 10 | + | else | |
| 11 | + | size="$2" | |
| 12 | + | fi | |
| 13 | + | echo "please don't run this script without reading it first" | |
| 14 | + | exit | |
| 15 | + | if (vultr-cli regions availability $region | grep $size); then | |
| 16 | + | python -c "from datetime import datetime, timedelta; print('est time of completion: {} (9 minutes)'.format(datetime.now()+timedelta(minutes=9)))" | |
| 17 | + | read ID <<<$((set -x; vultr-cli instance create --label "${region}w" --host "$region.w.$domain" --firewall-group a4496c76-4a45-4051-a923-3d2d08159dcc --script-id 03c1ae6a-59f6-4190-a8a1-af9f1e23c1f0 --region "$region" --os 371 --plan "$size") | egrep '^ID\t' | awk '{print $2}') | |
| 18 | + | echo https://my.vultr.com/subs/vps/novnc/?id=$ID | |
| 19 | + | echo -n Waiting for IP | |
| 20 | + | until vultr-cli instance list | grep "${region}w" | awk '{print $2}' | grep -v "0.0.0.0" >/dev/null; do | |
| 21 | + | echo -n "." | |
| 22 | + | sleep 1; | |
| 23 | + | done | |
| 24 | + | read IP <<<$(vultr-cli instance list | grep "${region}w" | awk '{print $2}') | |
| 25 | + | read DOID <<<$(doctl compute domain records list $domain | grep $region.w | awk '{print $1}') | |
| 26 | + | if [ -z "$DOID" ]; then | |
| 27 | + | (set -x; doctl compute domain records create $domain --record-name $region.w --record-type A --record-data $IP) | |
| 28 | + | else | |
| 29 | + | (set -x; doctl compute domain records update $domain --record-id $DOID --record-name $region.w --record-type A --record-data $IP) | |
| 30 | + | fi | |
| 31 | + | echo Waiting for ssh | |
| 32 | + | until ssh -o StrictHostKeyChecking=no administrator@$IP; do | |
| 33 | + | sleep 1 | |
| 34 | + | done | |
| 35 | + | if read -p "Delete instance?" a; then | |
| 36 | + | (set -x; vultr-cli instance delete $ID) | |
| 37 | + | fi | |
| 38 | + | else | |
| 39 | + | echo "$size not available in $region" | |
| 40 | + | fi | |
windows-init.cmd
| @@ -1,3 +1,5 @@ | |||
| 1 | + | rem replace all instances of alyssasmith.id.au with your own values, as well as the url for authorized keys | |
| 2 | + | ||
| 1 | 3 | powershell -Command "iwr https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x64.msi -OutFile c:\powershell.msi" | |
| 2 | 4 | msiexec /i c:\powershell.msi /quiet | |
| 3 | 5 | ||
| @@ -9,10 +11,10 @@ netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp | |||
| 9 | 11 | "C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 10 | 12 | "C:\Program Files\PowerShell\7\pwsh" -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 11 | 13 | netsh advfirewall firewall add rule name="22" dir=in action=allow protocol=tcp localport=22 | |
| 12 | - | set authkeysurl= | |
| 13 | - | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
| 14 | - | rem https://superuser.com/a/1605117 | |
| 14 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr example.com -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
| 15 | 15 | "C:\Program Files\PowerShell\7\pwsh" -Command "$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys; $acl.SetAccessRuleProtection($true, $false); $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule('Administrators','FullControl','Allow'); $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule('SYSTEM','FullControl','Allow'); $acl.SetAccessRule($administratorsRule); $acl.SetAccessRule($systemRule); $acl | Set-Acl" | |
| 16 | 16 | "C:\Program Files\PowerShell\7\pwsh" -Command "set-service -name sshd -StartupType Automatic" | |
| 17 | 17 | ||
| 18 | - | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr -useb get.scoop.sh | iex; scoop install git; scoop update; scoop bucket add extras; scoop install chromium rclone" | |
| 18 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr -useb get.scoop.sh | iex; scoop install git; scoop update; scoop bucket add extras; scoop install chromium rclone" | |
| 19 | + | ||
| 20 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "$_host = ((iwr http://169.254.169.254/v1/hostname).Content -replace '.w.alyssasmith.id.au$'); rename-computer -newname $_host" | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 2 deletions
windows-init.bat renamed to windows-init.cmd
| @@ -4,7 +4,6 @@ msiexec /i c:\powershell.msi /quiet | |||
| 4 | 4 | "C:\Program Files\PowerShell\7\pwsh" -Command "Invoke-WebRequest https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.11-I601-Win10.exe -OutFile c:\openvpn-setup.exe" | |
| 5 | 5 | c:\openvpn-setup.exe /S | |
| 6 | 6 | "C:\Program Files\PowerShell\7\pwsh" -Command "set-service -name OpenVPNService -StartupType Automatic" | |
| 7 | - | net start OpenVPNService | |
| 8 | 7 | netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp localport=3389 | |
| 9 | 8 | ||
| 10 | 9 | "C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| @@ -14,7 +13,6 @@ set authkeysurl= | |||
| 14 | 13 | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
| 15 | 14 | rem https://superuser.com/a/1605117 | |
| 16 | 15 | "C:\Program Files\PowerShell\7\pwsh" -Command "$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys; $acl.SetAccessRuleProtection($true, $false); $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule('Administrators','FullControl','Allow'); $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule('SYSTEM','FullControl','Allow'); $acl.SetAccessRule($administratorsRule); $acl.SetAccessRule($systemRule); $acl | Set-Acl" | |
| 17 | - | net start sshd | |
| 18 | 16 | "C:\Program Files\PowerShell\7\pwsh" -Command "set-service -name sshd -StartupType Automatic" | |
| 19 | 17 | ||
| 20 | 18 | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr -useb get.scoop.sh | iex; scoop install git; scoop update; scoop bucket add extras; scoop install chromium rclone" | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 1 insertion
windows-init.bat
| @@ -15,5 +15,6 @@ set authkeysurl= | |||
| 15 | 15 | rem https://superuser.com/a/1605117 | |
| 16 | 16 | "C:\Program Files\PowerShell\7\pwsh" -Command "$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys; $acl.SetAccessRuleProtection($true, $false); $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule('Administrators','FullControl','Allow'); $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule('SYSTEM','FullControl','Allow'); $acl.SetAccessRule($administratorsRule); $acl.SetAccessRule($systemRule); $acl | Set-Acl" | |
| 17 | 17 | net start sshd | |
| 18 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "set-service -name sshd -StartupType Automatic" | |
| 18 | 19 | ||
| 19 | 20 | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr -useb get.scoop.sh | iex; scoop install git; scoop update; scoop bucket add extras; scoop install chromium rclone" | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 2 insertions, 2 deletions
windows-init.bat
| @@ -9,11 +9,11 @@ netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp | |||
| 9 | 9 | ||
| 10 | 10 | "C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 11 | 11 | "C:\Program Files\PowerShell\7\pwsh" -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 12 | - | net start sshd | |
| 13 | - | netsh advfirewall firewall add rule name="vpn 22" dir=in action=allow protocol=tcp localport=22 | |
| 12 | + | netsh advfirewall firewall add rule name="22" dir=in action=allow protocol=tcp localport=22 | |
| 14 | 13 | set authkeysurl= | |
| 15 | 14 | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
| 16 | 15 | rem https://superuser.com/a/1605117 | |
| 17 | 16 | "C:\Program Files\PowerShell\7\pwsh" -Command "$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys; $acl.SetAccessRuleProtection($true, $false); $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule('Administrators','FullControl','Allow'); $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule('SYSTEM','FullControl','Allow'); $acl.SetAccessRule($administratorsRule); $acl.SetAccessRule($systemRule); $acl | Set-Acl" | |
| 17 | + | net start sshd | |
| 18 | 18 | ||
| 19 | 19 | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr -useb get.scoop.sh | iex; scoop install git; scoop update; scoop bucket add extras; scoop install chromium rclone" | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 8 deletions
windows-init.bat
| @@ -10,14 +10,6 @@ netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp | |||
| 10 | 10 | "C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 11 | 11 | "C:\Program Files\PowerShell\7\pwsh" -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 12 | 12 | net start sshd | |
| 13 | - | ||
| 14 | - | rem net stop sshd | |
| 15 | - | rem add the line | |
| 16 | - | rem Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo | |
| 17 | - | rem manually to c:\programdata\ssh\sshd_config, above the line "Match Group administrators" | |
| 18 | - | rem "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo' >> c:\programdata\ssh\sshd_config" | |
| 19 | - | rem net start sshd | |
| 20 | - | ||
| 21 | 13 | netsh advfirewall firewall add rule name="vpn 22" dir=in action=allow protocol=tcp localport=22 | |
| 22 | 14 | set authkeysurl= | |
| 23 | 15 | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 3 insertions, 1 deletion
windows-init.bat
| @@ -10,12 +10,14 @@ netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp | |||
| 10 | 10 | "C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 11 | 11 | "C:\Program Files\PowerShell\7\pwsh" -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 12 | 12 | net start sshd | |
| 13 | + | ||
| 13 | 14 | rem net stop sshd | |
| 14 | 15 | rem add the line | |
| 15 | 16 | rem Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo | |
| 16 | 17 | rem manually to c:\programdata\ssh\sshd_config, above the line "Match Group administrators" | |
| 17 | 18 | rem "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo' >> c:\programdata\ssh\sshd_config" | |
| 18 | - | net start sshd | |
| 19 | + | rem net start sshd | |
| 20 | + | ||
| 19 | 21 | netsh advfirewall firewall add rule name="vpn 22" dir=in action=allow protocol=tcp localport=22 | |
| 20 | 22 | set authkeysurl= | |
| 21 | 23 | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 1 insertion, 1 deletion
windows-init.bat
| @@ -10,7 +10,7 @@ netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp | |||
| 10 | 10 | "C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 11 | 11 | "C:\Program Files\PowerShell\7\pwsh" -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 12 | 12 | net start sshd | |
| 13 | - | net stop sshd | |
| 13 | + | rem net stop sshd | |
| 14 | 14 | rem add the line | |
| 15 | 15 | rem Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo | |
| 16 | 16 | rem manually to c:\programdata\ssh\sshd_config, above the line "Match Group administrators" | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 4 insertions, 4 deletions
windows-init.bat
| @@ -8,13 +8,13 @@ net start OpenVPNService | |||
| 8 | 8 | netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp localport=3389 | |
| 9 | 9 | ||
| 10 | 10 | "C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 11 | - | "C:\Program Files\PowerShell\7\pwsh" -Command "Install-Module -Force OpenSSHUtils -Scope AllUsers" | |
| 12 | 11 | "C:\Program Files\PowerShell\7\pwsh" -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 13 | 12 | net start sshd | |
| 14 | 13 | net stop sshd | |
| 15 | - | "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo' >> c:\programdata\ssh\sshd_config" | |
| 16 | - | "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'PubkeyAuthentication yes' >> c:\programdata\ssh\sshd_config" | |
| 17 | - | "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'PasswordAuthentication no' >> c:\programdata\ssh\sshd_config" | |
| 14 | + | rem add the line | |
| 15 | + | rem Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo | |
| 16 | + | rem manually to c:\programdata\ssh\sshd_config, above the line "Match Group administrators" | |
| 17 | + | rem "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo' >> c:\programdata\ssh\sshd_config" | |
| 18 | 18 | net start sshd | |
| 19 | 19 | netsh advfirewall firewall add rule name="vpn 22" dir=in action=allow protocol=tcp localport=22 | |
| 20 | 20 | set authkeysurl= | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 11 insertions, 16 deletions
windows-init.bat
| @@ -1,30 +1,25 @@ | |||
| 1 | 1 | powershell -Command "iwr https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x64.msi -OutFile c:\powershell.msi" | |
| 2 | 2 | msiexec /i c:\powershell.msi /quiet | |
| 3 | - | set path="C:\Program Files\PowerShell\7\;%path%" | |
| 4 | 3 | ||
| 5 | - | pwsh -Command "Invoke-WebRequest https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.11-I601-Win10.exe -OutFile c:\openvpn-setup.exe" | |
| 4 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "Invoke-WebRequest https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.11-I601-Win10.exe -OutFile c:\openvpn-setup.exe" | |
| 6 | 5 | c:\openvpn-setup.exe /S | |
| 7 | - | pwsh -Command "set-service -name OpenVPNService -StartupType Automatic" | |
| 6 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "set-service -name OpenVPNService -StartupType Automatic" | |
| 8 | 7 | net start OpenVPNService | |
| 9 | 8 | netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp localport=3389 | |
| 10 | 9 | ||
| 11 | - | pwsh -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 12 | - | pwsh -Command "Install-Module -Force OpenSSHUtils -Scope AllUsers" | |
| 13 | - | pwsh -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 10 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 11 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "Install-Module -Force OpenSSHUtils -Scope AllUsers" | |
| 12 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 14 | 13 | net start sshd | |
| 15 | 14 | net stop sshd | |
| 16 | - | pwsh -Command "echo 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo' >> c:\programdata\ssh\sshd_config" | |
| 17 | - | pwsh -Command "echo 'PubkeyAuthentication yes' >> c:\programdata\ssh\sshd_config" | |
| 18 | - | pwsh -Command "echo 'PasswordAuthentication no' >> c:\programdata\ssh\sshd_config" | |
| 15 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo' >> c:\programdata\ssh\sshd_config" | |
| 16 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'PubkeyAuthentication yes' >> c:\programdata\ssh\sshd_config" | |
| 17 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "echo 'PasswordAuthentication no' >> c:\programdata\ssh\sshd_config" | |
| 19 | 18 | net start sshd | |
| 20 | 19 | netsh advfirewall firewall add rule name="vpn 22" dir=in action=allow protocol=tcp localport=22 | |
| 21 | 20 | set authkeysurl= | |
| 22 | - | pwsh -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
| 21 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
| 23 | 22 | rem https://superuser.com/a/1605117 | |
| 24 | - | pwsh -Command "$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys; $acl.SetAccessRuleProtection($true, $false); $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule('Administrators','FullControl','Allow'); $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule('SYSTEM','FullControl','Allow'); $acl.SetAccessRule($administratorsRule); $acl.SetAccessRule($systemRule); $acl | Set-Acl" | |
| 23 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys; $acl.SetAccessRuleProtection($true, $false); $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule('Administrators','FullControl','Allow'); $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule('SYSTEM','FullControl','Allow'); $acl.SetAccessRule($administratorsRule); $acl.SetAccessRule($systemRule); $acl | Set-Acl" | |
| 25 | 24 | ||
| 26 | - | pwsh -Command "iwr -useb get.scoop.sh | iex" | |
| 27 | - | pwsh -Command "scoop install git" | |
| 28 | - | pwsh -Command "scoop update" | |
| 29 | - | pwsh -Command "scoop bucket add extras" | |
| 30 | - | pwsh -Command "scoop install chromium rclone" | |
| 25 | + | "C:\Program Files\PowerShell\7\pwsh" -Command "iwr -useb get.scoop.sh | iex; scoop install git; scoop update; scoop bucket add extras; scoop install chromium rclone" | |
Alyssa Smith revised this gist . Go to revision
1 file changed, 30 insertions
windows-init.bat(file created)
| @@ -0,0 +1,30 @@ | |||
| 1 | + | powershell -Command "iwr https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x64.msi -OutFile c:\powershell.msi" | |
| 2 | + | msiexec /i c:\powershell.msi /quiet | |
| 3 | + | set path="C:\Program Files\PowerShell\7\;%path%" | |
| 4 | + | ||
| 5 | + | pwsh -Command "Invoke-WebRequest https://swupdate.openvpn.org/community/releases/openvpn-install-2.4.11-I601-Win10.exe -OutFile c:\openvpn-setup.exe" | |
| 6 | + | c:\openvpn-setup.exe /S | |
| 7 | + | pwsh -Command "set-service -name OpenVPNService -StartupType Automatic" | |
| 8 | + | net start OpenVPNService | |
| 9 | + | netsh advfirewall firewall add rule name="3389" dir=in action=allow protocol=tcp localport=3389 | |
| 10 | + | ||
| 11 | + | pwsh -Command "Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | |
| 12 | + | pwsh -Command "Install-Module -Force OpenSSHUtils -Scope AllUsers" | |
| 13 | + | pwsh -Command "New-ItemProperty -Path 'HKLM:\SOFTWARE\OpenSSH' -Name DefaultShell -Value 'C:\Program Files\PowerShell\7\pwsh.exe' -PropertyType String -Force" | |
| 14 | + | net start sshd | |
| 15 | + | net stop sshd | |
| 16 | + | pwsh -Command "echo 'Subsystem powershell c:/progra~1/powershell/7/pwsh.exe -sshs -NoLogo' >> c:\programdata\ssh\sshd_config" | |
| 17 | + | pwsh -Command "echo 'PubkeyAuthentication yes' >> c:\programdata\ssh\sshd_config" | |
| 18 | + | pwsh -Command "echo 'PasswordAuthentication no' >> c:\programdata\ssh\sshd_config" | |
| 19 | + | net start sshd | |
| 20 | + | netsh advfirewall firewall add rule name="vpn 22" dir=in action=allow protocol=tcp localport=22 | |
| 21 | + | set authkeysurl= | |
| 22 | + | pwsh -Command "iwr %authkeysurl% -OutFile c:\programdata\ssh\administrators_authorized_keys" | |
| 23 | + | rem https://superuser.com/a/1605117 | |
| 24 | + | pwsh -Command "$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys; $acl.SetAccessRuleProtection($true, $false); $administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule('Administrators','FullControl','Allow'); $systemRule = New-Object system.security.accesscontrol.filesystemaccessrule('SYSTEM','FullControl','Allow'); $acl.SetAccessRule($administratorsRule); $acl.SetAccessRule($systemRule); $acl | Set-Acl" | |
| 25 | + | ||
| 26 | + | pwsh -Command "iwr -useb get.scoop.sh | iex" | |
| 27 | + | pwsh -Command "scoop install git" | |
| 28 | + | pwsh -Command "scoop update" | |
| 29 | + | pwsh -Command "scoop bucket add extras" | |
| 30 | + | pwsh -Command "scoop install chromium rclone" | |