Windows 2025
Sponsored Link

OpenSSH : Change default Shell2024/11/27

 

When login to OpenSSH Server from Clients, Command prompt runs as default Shell,
however, if you'd like to change it to PowerShell, Configure like follows.

[1] Run PowerShell on OpenSSH Server and Change setting.
# confirm the PATH of powershell command
PS C:\Users\Administrator> Get-Command powershell | Format-Table -AutoSize -Wrap 

CommandType Name           Version      Source
----------- ----           -------      ------
Application powershell.exe 10.0.26100.1 C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe


# set DefaultShell=PowerShell in registry entry of OpenSSH
# for the PATH of PowerShell, specify the result of above
PS C:\Users\Administrator> New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -PropertyType String -Force 

DefaultShell : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
PSPath       : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE
PSChildName  : OpenSSH
PSDrive      : HKLM
PSProvider   : Microsoft.PowerShell.Core\Registry
Matched Content