Created
December 13, 2022 04:25
-
-
Save jarkkojs/9cd9300b10613cc32348b3e3d5acf1ab to your computer and use it in GitHub Desktop.
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
if ((Get-NetFirewallRule | Where-Object -Property DisplayName -eq 'wsl_ssh').count -eq 0) | |
{ | |
Write-Output 'Creating ''wsl_ssh'' firewall rule' | |
New-NetFirewallRule -DisplayName wsl_ssh ` | |
-Direction Inbound ` | |
-Protocol TCP ` | |
-LocalPort 10022 ` | |
-Action Allow ` | |
| Out-Null | |
} | |
# Remove forward to the old guest address first: | |
Remove-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\PortProxy\v4tov4\tcp' '*/10022' ` | |
-ErrorAction SilentlyContinue | |
$guestAddress = (wsl hostname -i).split(" ")[0] | |
netsh interface portproxy add v4tov4 listenport=10022 connectport=22 connectaddress=$guestAddress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment