Skip to content

Commit 54b7fe9

Browse files
authored
feat: add support for a powershell install script for a dev env (#4317)
1 parent ca7a0f2 commit 54b7fe9

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

scripts/windows/install.ps1

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Ensure you are running this powershell script on Windows as an administrator
2+
3+
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
4+
5+
# Install the OpenSSH Client
6+
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
7+
8+
# Install the OpenSSH Server
9+
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
10+
11+
# Start the sshd service
12+
Start-Service sshd
13+
14+
# OPTIONAL but recommended:
15+
Set-Service -Name sshd -StartupType 'Automatic'
16+
17+
# Confirm the Firewall rule is configured. It should be created automatically by setup. Run the following to verify
18+
if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue | Select-Object Name, Enabled)) {
19+
Write-Output "Firewall Rule 'OpenSSH-Server-In-TCP' does not exist, creating it..."
20+
New-NetFirewallRule -Name 'OpenSSH-Server-In-TCP' -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
21+
} else {
22+
Write-Output "Firewall rule 'OpenSSH-Server-In-TCP' has been created and exists."
23+
}
24+
25+
# Replace this line with your own SSH key
26+
echo "INSERT YOUR PUBLIC SSH KEY (id_rsa.pub or id_ed25519.pub) IN PLAIN TEXT HERE" > "C:\ProgramData\ssh\administrators_authorized_keys"
27+
28+
# Give the right permission on the file
29+
icacls.exe "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
30+
31+
# Install Chocolatey
32+
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
33+
34+
# Install golang and git
35+
choco install -y golang git
36+
37+
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
38+
refreshenv
39+
40+
go version
41+
42+
git version

0 commit comments

Comments
 (0)