Skip to content

Instantly share code, notes, and snippets.

@mcx808
Created September 27, 2024 10:39
Show Gist options
  • Save mcx808/b375be86c8df1a4196cb0e7f37f4ef4e to your computer and use it in GitHub Desktop.
Save mcx808/b375be86c8df1a4196cb0e7f37f4ef4e to your computer and use it in GitHub Desktop.
Enable Powershell Subsystem for SSH on Linux
$subsystemConfig = @"
Subsystem powershell /usr/bin/pwsh -sshs -nologo`n
"@
$existingContent = Get-Content -Path /etc/ssh/sshd_config -Raw
$lastSubsystemIndex = $existingContent.LastIndexOf("Subsystem")
$newContent = $existingContent.Insert($lastSubsystemIndex, $subsystemConfig)
Set-Content /etc/ssh/sshd_config -Value $newContent
systemctl restart sshd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment