- Download SSH-server from github https://github.com/PowerShell/Win32-OpenSSH/releases/ and install.
- Start and enable auto-start after booting in powershell console:
Start-Service sshd Set-Service -Name sshd -StartupType 'Automatic'
- Allow incoming connection in Windows Firewall:
New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22
- Enable password-less authentication:
Add-Content -Path "C:\ProgramData\ssh\administrators_authorized_keys" -Value "your_public_key_here" icacls "C:\ProgramData\ssh\administrators_authorized_keys" /inheritance:r /grant "SYSTEM:(F)" /grant "ADMINISTRATORS:(F)"
- To make PowerShell the default shell permanently:
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" ` -Name DefaultShell ` -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" ` -PropertyType String -Force
After that you can run from linux commands on remove windows-machine like this:
ssh myuser@192.168.0.13 'gps | where Name -like "*notepad*"' ssh myuser@192.168.0.13 'Stop-Process -Name "notepad" -Force'
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.
You must be logged in to post a comment.