Created
December 13, 2022 15:29
-
-
Save jarkkojs/b188f3c19d9cfe4ad1340b5bddd0102a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
$wsl_netif_index = (Get-NetAdapter | Where-Object -Property Name -Match "WSL").InterfaceIndex | |
$wsl_ip = (Get-NetIPAddress -InterfaceIndex $wsl_netif_index -AddressFamily IPv4).IPAddress | |
Write-Output 'WSL IP address: ' $wsl_ip | |
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-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\PortProxy\v4tov4\tcp' '*/10022' | |
netsh interface portproxy add v4tov4 listenport=10022 connectport=22 connectaddress=$wsl_ip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment