Configure default shell initialized by OpenSSH on Windows 7

Is there a way to configure OpenSSH on Windows 7 in to initialize another shell other than the default Windows command shell?

me@linuxhost:~
$ ssh me@windowshost
me@windowshost's password:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

me@windowshost C:\Users\me> exit
Connection to windowshost closed.
me@linuxhost:~
$

Alternately, installing Cygwin and including OpenSSH in the additional Net packages results in a default Cygwin shell, so the same question stands: is there a way to configure the shell initialized by OpenSSH after installation?

EDIT:

Thank you @simlev for your suggestion to use Cygwin I have reworded my question to more clearly represent my problem.


Win32-OpenSSH hardcodes cmd.exe as the default shell in the source: see lines 978-984 and 1081-1086 of shell-host.c. With that said, it appears the only way to change the default shell is to change it in those locations and recompile OpenSSH.


According to this you can configure the DefaultShell for OpenSSH in Windows, to be PowerShell or any other executable.

It requires to add the String Registry Key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShell with the path of the Shell Executable as string value, i.e.:

  • Powershell: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

  • CygWin Bash: C:\Cygwin64\bin\bash.exe

I tested it and works as expected.


From the Win32-OpenSSH wiki:

On the server side, configure the default ssh shell in the windows registry.

  • Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShell - full path of the shell executable
  • Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShellCommandOption (optional) - switch that the configured default shell requires to execute a command, immediately exit and return to the calling process. By default this is -c.
  • Computer\HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH\DefaultShellEscapeArguments (optional) - flag that allow you to skip escaping the arguments of default shell. By default this is 0. This option is only applicable to shells other than powershell, powershell, bash, cygwin, cmd, and ssh-shellhost.exe.