Windows 2022
Sponsored Link

OpenSSH : デフォルトシェルを変更する2021/12/01

 
OpenSSH サーバーに SSH ログインすると、デフォルトではコマンドプロンプトが起動しますが、PowerShell に変更したい場合は以下のように設定します。
[1] OpenSSH サーバー上で PowerShell を起動し、設定を変更します。
# powershell コマンドの PATH 確認
PS C:\Users\Administrator> Get-Command powershell | Format-Table -AutoSize -Wrap 

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


# OpenSSH のレジストリーエントリーに DefaultShell=PowerShell を設定
# PowerShell の PATH は上で確認した PATH を指定する
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
関連コンテンツ