To make Git Bash the default shell for SSH connections on a Windows 10 machine, follow these steps:
Step 1: Enable SSH Server on Windows 10
Open PowerShell as an Administrator.
Install OpenSSH Server:
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
Enable and Start the SSH Server:
Set-Service -Name sshd -StartupType 'Automatic'
Start-Service -Name sshd
Step 2: Install Git via Chocolatey
Install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Install Git:
choco install git -y
Step 3: Set Git Bash as the Default Shell for SSH
Run the following command to set Git Bash as the default shell for the SSH service:
This command updates the registry to make Git Bash the default shell for SSH connections.
New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name "DefaultShell" -Value "C:\Program Files\Git\bin\bash.exe" -PropertyType String -Force
Step 4: Test SSH Login
On another machine, open a terminal and try logging in via SSH:
Upon successful login, you should be automatically switched to Git Bash.
ssh <username>@<your-windows-machine>
e.g. ssh [email protected]