Set Git Bash as the Default Shell for SSH on Windows 10
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:
| |
Enable and Start the SSH Server:
| |
Step 2: Install Git via Chocolatey
Install Chocolatey:
| |
Install Git:
| |
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.
| |
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.
| |
e.g. ssh user01@10.1.1.254
Key-based authentication in OpenSSH for Windows
Move to the .ssh Directory(Client):
1cd .sshChanges the current directory to
.ssh, which typically stores SSH keys.Generate a New SSH Key Pair:
1ssh-keygen|– id_rsa
|– id_rsa.pub
Copy the Public Key to the Remote Server:
as name:
administrators_authorized_keys
1scp id_rsa.pub admin@10.2.2.80:administrators_authorized_keysUses
scp(secure copy) to transfer the public key fileid_rsa.pubto the remote server at IP10.2.2.80. The file will be saved asadministrators_authorized_keyson the remote server under theadminuser’s home directory.SSH into the Remote Server(Server):
1ssh USER@RemoteIPSSH connection to the remote server specified by
RemoteIPusing theUSERaccount.1ssh admin@10.2.2.80adminas username and10.2.2.80with the IP address of the remote server.Move the Key File to the SSH Configuration Directory:
1move administrators_authorized_keys %ProgramData%\sshMoves the
administrators_authorized_keysfile to the%ProgramData%\sshdirectory, which is where Windows stores SSH configuration files.Move to the SSH Directory:
1cd %ProgramData%\sshChanges the current directory to
%ProgramData%\ssh.Set Permissions on the Authorized Keys File:
bash
1icacls administrators_authorized_keys /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"Modifies the permissions of the
administrators_authorized_keysfile. It removes inherited permissions and grants full control to theAdministratorsgroup and theSYSTEMaccount.Use the SSH keys to connect to a remote system without using passwords(Test).
| |
One-time to Deploy a SSH Public Key on Windows 10
Run “PowerShell” as administrator
Type [A] to grant unrestricted access.
This script consolidates all steps.🚀
- Check if OpenSSH Server is installed
- Check if SSH service is running
- Fetch the SSH public key from my github
- Display network configuration details
| |
Connects to a remote server without a password, immediately shuts down the remote server, force-closing all applications.
