Setting to use git-bash as default shell when connecting remotely via OpenSSH to Windows Server 2016

7,485

Solution 1

This should be all you need:

New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "C:\Program Files\Git\bin\bash.exe" -PropertyType String -Force

Solution 2

If you need to use the cygwin provided bash, this worked for me:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\OpenSSH]
"DefaultShell"="C:\\cygwin64\\Cygwin.bat"
Share:
7,485

Related videos on Youtube

Clay
Author by

Clay

Updated on September 18, 2022

Comments

  • Clay
    Clay over 1 year

    The Powershell OpenSSH website has good instructions on how to install and use OpenSSH.

    These include how to "Configuring the default ssh shell (optional)"

    If I elect to use git-bash instead of powershell, what -Value do I put into the following other than "/c"

    New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShellCommandOption -Value "/c" -PropertyType String -Force
    

    I get a blank screen when I set the default shell to be git-bash.
    I tried "-c" and "-l -i" but neither one worked and I am still getting a blank screen.

  • bertieb
    bertieb over 5 years
    Thanks for your answer! Can you explain it? :)
  • user2819573
    user2819573 over 5 years
    From here where they are setting the default shell to powershell, answer above just substitutes git bash for powershell github.com/PowerShell/Win32-OpenSSH/wiki/DefaultShell
  • Ray Foss
    Ray Foss almost 4 years
    C:\Windows\System32\bash.exe also works for opening WSL bash on windows!
  • Admin
    Admin almost 2 years
    @RayFoss, C:\Windows\System32\bash.exe works only when you install a Linux distro on Windows. For me, it asked me to install a distro :)
  • Admin
    Admin almost 2 years
    @user2819573 Thanks for your answer, I was using the GUI version .exe file in "C:\Program Files\Git\git-bash.exe", as soon as I changed path to "C:\Program Files\Git\bin/bash.exe", it started working :)