Configure default shell initialized by OpenSSH on Windows 7












4















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:Usersme> 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.










share|improve this question

























  • You can do this easier with a dedicated tool. See for example if you like Gitblit.

    – harrymc
    Feb 27 '17 at 20:26


















4















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:Usersme> 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.










share|improve this question

























  • You can do this easier with a dedicated tool. See for example if you like Gitblit.

    – harrymc
    Feb 27 '17 at 20:26
















4












4








4


3






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:Usersme> 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.










share|improve this question
















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:Usersme> 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.







ssh openssh sshd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 28 '17 at 17:58







mlegge

















asked Feb 24 '17 at 21:35









mleggemlegge

7319




7319













  • You can do this easier with a dedicated tool. See for example if you like Gitblit.

    – harrymc
    Feb 27 '17 at 20:26





















  • You can do this easier with a dedicated tool. See for example if you like Gitblit.

    – harrymc
    Feb 27 '17 at 20:26



















You can do this easier with a dedicated tool. See for example if you like Gitblit.

– harrymc
Feb 27 '17 at 20:26







You can do this easier with a dedicated tool. See for example if you like Gitblit.

– harrymc
Feb 27 '17 at 20:26












3 Answers
3






active

oldest

votes


















2














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.






share|improve this answer
























  • With Powershell being under heavy development, things have changed: see Brethlosze's recent answer.

    – simlev
    Jan 23 at 18:03



















4





+50









My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.



user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3


The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:



db_shell: /bin/sh


possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.



There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.




  1. Download winpty for Cygwin and extract winpty.exe, winpty.dll and winpty-agent.exe to /bin. If you do this from outside of a Cygwin terminal, look for a bin subdirectory of the Cygwin installation folder.


  2. Create two batch files in /binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course <cygwin path> is a placeholder for the path you installed Cygwin to (by default it's C:cygwin):



    @ECHO OFF
    <cygwin path>binwinpty.exe cmd


    and



    @ECHO OFF
    <cygwin path>binwinpty.exe powershell



  3. Put one of these lines into /etc/nsswitch.conf:



    db_shell: /bin/winpty-cmd.bat


    or



    db_shell: /bin/winpty-powershell.bat


  4. Restart the sshd service.




Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:



"Use git bash instead of cmd when sshing from Linux"



In addition to using Cygwin to accept ssh connections on the Windows machine:




  1. Follow step 1. above.


  2. Create a file called <cygwin path>binwinpty-gitbash.bat with these contents, where <cygwin path> is a placeholder for the path you installed git-for-windows to (by default it's C:Program FilesGit):



    @ECHO OFF
    SET PATH="/bin"
    <cygwin path>binwinpty.exe "<git path>binbash.exe"



  3. Put this line into /etc/nsswitch.conf:



    db_shell: /bin/winpty-gitbash.bat


  4. Restart the sshd service.




Update - September 2018:



Things change, and Win32-OpenSSH now allows choosing the default shell (any shell actually) by setting its path in a registry key. See Brethlosze's recent answer.






share|improve this answer


























  • This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).

    – simlev
    Feb 27 '17 at 19:35





















1














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 ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:




  • Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


  • CygWin Bash: C:Cygwin64binbash.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.





  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell - full path of the shell executable


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellCommandOption
    (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.


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellEscapeArguments
    (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.







share|improve this answer





















  • 1





    Thank you, I like this! The page you link to was first created on 13 Sep 2018, it was about time!

    – simlev
    Jan 23 at 17:57











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1182522%2fconfigure-default-shell-initialized-by-openssh-on-windows-7%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














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.






share|improve this answer
























  • With Powershell being under heavy development, things have changed: see Brethlosze's recent answer.

    – simlev
    Jan 23 at 18:03
















2














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.






share|improve this answer
























  • With Powershell being under heavy development, things have changed: see Brethlosze's recent answer.

    – simlev
    Jan 23 at 18:03














2












2








2







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.






share|improve this answer













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.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 2 '17 at 5:10









Joseph SibleJoseph Sible

991114




991114













  • With Powershell being under heavy development, things have changed: see Brethlosze's recent answer.

    – simlev
    Jan 23 at 18:03



















  • With Powershell being under heavy development, things have changed: see Brethlosze's recent answer.

    – simlev
    Jan 23 at 18:03

















With Powershell being under heavy development, things have changed: see Brethlosze's recent answer.

– simlev
Jan 23 at 18:03





With Powershell being under heavy development, things have changed: see Brethlosze's recent answer.

– simlev
Jan 23 at 18:03













4





+50









My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.



user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3


The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:



db_shell: /bin/sh


possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.



There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.




  1. Download winpty for Cygwin and extract winpty.exe, winpty.dll and winpty-agent.exe to /bin. If you do this from outside of a Cygwin terminal, look for a bin subdirectory of the Cygwin installation folder.


  2. Create two batch files in /binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course <cygwin path> is a placeholder for the path you installed Cygwin to (by default it's C:cygwin):



    @ECHO OFF
    <cygwin path>binwinpty.exe cmd


    and



    @ECHO OFF
    <cygwin path>binwinpty.exe powershell



  3. Put one of these lines into /etc/nsswitch.conf:



    db_shell: /bin/winpty-cmd.bat


    or



    db_shell: /bin/winpty-powershell.bat


  4. Restart the sshd service.




Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:



"Use git bash instead of cmd when sshing from Linux"



In addition to using Cygwin to accept ssh connections on the Windows machine:




  1. Follow step 1. above.


  2. Create a file called <cygwin path>binwinpty-gitbash.bat with these contents, where <cygwin path> is a placeholder for the path you installed git-for-windows to (by default it's C:Program FilesGit):



    @ECHO OFF
    SET PATH="/bin"
    <cygwin path>binwinpty.exe "<git path>binbash.exe"



  3. Put this line into /etc/nsswitch.conf:



    db_shell: /bin/winpty-gitbash.bat


  4. Restart the sshd service.




Update - September 2018:



Things change, and Win32-OpenSSH now allows choosing the default shell (any shell actually) by setting its path in a registry key. See Brethlosze's recent answer.






share|improve this answer


























  • This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).

    – simlev
    Feb 27 '17 at 19:35


















4





+50









My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.



user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3


The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:



db_shell: /bin/sh


possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.



There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.




  1. Download winpty for Cygwin and extract winpty.exe, winpty.dll and winpty-agent.exe to /bin. If you do this from outside of a Cygwin terminal, look for a bin subdirectory of the Cygwin installation folder.


  2. Create two batch files in /binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course <cygwin path> is a placeholder for the path you installed Cygwin to (by default it's C:cygwin):



    @ECHO OFF
    <cygwin path>binwinpty.exe cmd


    and



    @ECHO OFF
    <cygwin path>binwinpty.exe powershell



  3. Put one of these lines into /etc/nsswitch.conf:



    db_shell: /bin/winpty-cmd.bat


    or



    db_shell: /bin/winpty-powershell.bat


  4. Restart the sshd service.




Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:



"Use git bash instead of cmd when sshing from Linux"



In addition to using Cygwin to accept ssh connections on the Windows machine:




  1. Follow step 1. above.


  2. Create a file called <cygwin path>binwinpty-gitbash.bat with these contents, where <cygwin path> is a placeholder for the path you installed git-for-windows to (by default it's C:Program FilesGit):



    @ECHO OFF
    SET PATH="/bin"
    <cygwin path>binwinpty.exe "<git path>binbash.exe"



  3. Put this line into /etc/nsswitch.conf:



    db_shell: /bin/winpty-gitbash.bat


  4. Restart the sshd service.




Update - September 2018:



Things change, and Win32-OpenSSH now allows choosing the default shell (any shell actually) by setting its path in a registry key. See Brethlosze's recent answer.






share|improve this answer


























  • This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).

    – simlev
    Feb 27 '17 at 19:35
















4





+50







4





+50



4




+50





My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.



user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3


The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:



db_shell: /bin/sh


possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.



There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.




  1. Download winpty for Cygwin and extract winpty.exe, winpty.dll and winpty-agent.exe to /bin. If you do this from outside of a Cygwin terminal, look for a bin subdirectory of the Cygwin installation folder.


  2. Create two batch files in /binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course <cygwin path> is a placeholder for the path you installed Cygwin to (by default it's C:cygwin):



    @ECHO OFF
    <cygwin path>binwinpty.exe cmd


    and



    @ECHO OFF
    <cygwin path>binwinpty.exe powershell



  3. Put one of these lines into /etc/nsswitch.conf:



    db_shell: /bin/winpty-cmd.bat


    or



    db_shell: /bin/winpty-powershell.bat


  4. Restart the sshd service.




Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:



"Use git bash instead of cmd when sshing from Linux"



In addition to using Cygwin to accept ssh connections on the Windows machine:




  1. Follow step 1. above.


  2. Create a file called <cygwin path>binwinpty-gitbash.bat with these contents, where <cygwin path> is a placeholder for the path you installed git-for-windows to (by default it's C:Program FilesGit):



    @ECHO OFF
    SET PATH="/bin"
    <cygwin path>binwinpty.exe "<git path>binbash.exe"



  3. Put this line into /etc/nsswitch.conf:



    db_shell: /bin/winpty-gitbash.bat


  4. Restart the sshd service.




Update - September 2018:



Things change, and Win32-OpenSSH now allows choosing the default shell (any shell actually) by setting its path in a registry key. See Brethlosze's recent answer.






share|improve this answer















My warm recommendation is to use Cygwin to accept ssh connections on your Windows machine. This would allow you to scp to and from it, as well as login from a remote system via ssh to a Bash shell and command-line git.



user@linuxhost$ ssh 192.168.x.x
Last login: Sun Feb 12 08:20:07 2017 from 10.x.x.x
user@windowshost$ echo $0 && git --version
-bash
git version 2.8.3


The shell can of course be customized: ash, bash, dash and sh are included by default, but just run the Cygwin installer and you can add your choice of zsh, mksh, tcsh or posh. Then add the following line to /etc/nsswitch.conf:



db_shell: /bin/sh


possibly substituting /usr/bin/sh with the path to your preferred shell. All Cygwin processes (terminal windows and sshd service) must be restarted for the setting to take effect.



There is even a way to get a cmd or powershell prompt upon login, which I recently found out about on Stackoverflow.




  1. Download winpty for Cygwin and extract winpty.exe, winpty.dll and winpty-agent.exe to /bin. If you do this from outside of a Cygwin terminal, look for a bin subdirectory of the Cygwin installation folder.


  2. Create two batch files in /binand make sure they have execute permissions. Let's name them winpty-cmd.bat and winpty-powershell.bat and fill them with the following contents, where of course <cygwin path> is a placeholder for the path you installed Cygwin to (by default it's C:cygwin):



    @ECHO OFF
    <cygwin path>binwinpty.exe cmd


    and



    @ECHO OFF
    <cygwin path>binwinpty.exe powershell



  3. Put one of these lines into /etc/nsswitch.conf:



    db_shell: /bin/winpty-cmd.bat


    or



    db_shell: /bin/winpty-powershell.bat


  4. Restart the sshd service.




Since the title has been "reworded" and my post might now seem sligthly out of place, allow me to directly answer the original question:



"Use git bash instead of cmd when sshing from Linux"



In addition to using Cygwin to accept ssh connections on the Windows machine:




  1. Follow step 1. above.


  2. Create a file called <cygwin path>binwinpty-gitbash.bat with these contents, where <cygwin path> is a placeholder for the path you installed git-for-windows to (by default it's C:Program FilesGit):



    @ECHO OFF
    SET PATH="/bin"
    <cygwin path>binwinpty.exe "<git path>binbash.exe"



  3. Put this line into /etc/nsswitch.conf:



    db_shell: /bin/winpty-gitbash.bat


  4. Restart the sshd service.




Update - September 2018:



Things change, and Win32-OpenSSH now allows choosing the default shell (any shell actually) by setting its path in a registry key. See Brethlosze's recent answer.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 23 at 18:12

























answered Feb 27 '17 at 19:03









simlevsimlev

3,0263527




3,0263527













  • This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).

    – simlev
    Feb 27 '17 at 19:35





















  • This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).

    – simlev
    Feb 27 '17 at 19:35



















This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).

– simlev
Feb 27 '17 at 19:35







This does not make use of the tools you mention (OpenSSH and Git Bash) but allows you to reach your goals (scp, Bash).

– simlev
Feb 27 '17 at 19:35













1














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 ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:




  • Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


  • CygWin Bash: C:Cygwin64binbash.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.





  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell - full path of the shell executable


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellCommandOption
    (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.


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellEscapeArguments
    (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.







share|improve this answer





















  • 1





    Thank you, I like this! The page you link to was first created on 13 Sep 2018, it was about time!

    – simlev
    Jan 23 at 17:57
















1














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 ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:




  • Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


  • CygWin Bash: C:Cygwin64binbash.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.





  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell - full path of the shell executable


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellCommandOption
    (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.


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellEscapeArguments
    (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.







share|improve this answer





















  • 1





    Thank you, I like this! The page you link to was first created on 13 Sep 2018, it was about time!

    – simlev
    Jan 23 at 17:57














1












1








1







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 ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:




  • Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


  • CygWin Bash: C:Cygwin64binbash.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.





  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell - full path of the shell executable


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellCommandOption
    (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.


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellEscapeArguments
    (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.







share|improve this answer















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 ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell with the path of the Shell Executable as string value, i.e.:




  • Powershell: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe


  • CygWin Bash: C:Cygwin64binbash.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.





  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShell - full path of the shell executable


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellCommandOption
    (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.


  • ComputerHKEY_LOCAL_MACHINESOFTWAREOpenSSHDefaultShellEscapeArguments
    (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.








share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 23 at 18:01









simlev

3,0263527




3,0263527










answered Dec 7 '18 at 1:08









BrethloszeBrethlosze

1279




1279








  • 1





    Thank you, I like this! The page you link to was first created on 13 Sep 2018, it was about time!

    – simlev
    Jan 23 at 17:57














  • 1





    Thank you, I like this! The page you link to was first created on 13 Sep 2018, it was about time!

    – simlev
    Jan 23 at 17:57








1




1





Thank you, I like this! The page you link to was first created on 13 Sep 2018, it was about time!

– simlev
Jan 23 at 17:57





Thank you, I like this! The page you link to was first created on 13 Sep 2018, it was about time!

– simlev
Jan 23 at 17:57


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1182522%2fconfigure-default-shell-initialized-by-openssh-on-windows-7%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

is 'sed' thread safe

How to make a Squid Proxy server?