--- Title: Setting Up sshd under WSL2 Date: 2023-03-25 Sequence: 1 Tags:  ---
I want to be able to launch scripts on my windows machine from my server. Something like launching firefox pointed at a URL but driven by server. This requires sshing over to my windows machine, copying over a script and then running that script. This is something wintegrate can do natively but it executes VBS and the emulator itself has those functions baked in.
My method will be to set up ssh on the windows machine and then scp a file over and then use ssh to run the script. Voila! My server can then trigger events on my PC.
The first step s install OpenSSH under windows and change the default shell. This way I can use the native ssh server for windows rather than fudge it through wsl2.
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*' Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 Set-Service -Name sshd -StartupType 'Automatic' New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\WINDOWS\System32\bash.exe" -PropertyType String -Force
sudo apt install openssh-server sudo service sshd start
Update ~/.ssh/authorized_keys with the public key of the machine you are connecting from.
cat vscode_rsa.pub >> ~/.ssh/authorized_keys