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):
1
cd .ssh
Changes the current directory to
.ssh
, which typically stores SSH keys.Generate a New SSH Key Pair:
1
ssh-keygen
|– id_rsa
|– id_rsa.pub
Copy the Public Key to the Remote Server:
as name:
administrators_authorized_keys
1
scp id_rsa.pub admin@10.2.2.80:administrators_authorized_keys
Uses
scp
(secure copy) to transfer the public key fileid_rsa.pub
to the remote server at IP10.2.2.80
. The file will be saved asadministrators_authorized_keys
on the remote server under theadmin
user’s home directory.SSH into the Remote Server(Server):
1
ssh USER@RemoteIP
SSH connection to the remote server specified by
RemoteIP
using theUSER
account.1
ssh admin@10.2.2.80
admin
as username and10.2.2.80
with the IP address of the remote server.Move the Key File to the SSH Configuration Directory:
1
move administrators_authorized_keys %ProgramData%\ssh
Moves the
administrators_authorized_keys
file to the%ProgramData%\ssh
directory, which is where Windows stores SSH configuration files.Move to the SSH Directory:
1
cd %ProgramData%\ssh
Changes the current directory to
%ProgramData%\ssh
.Set Permissions on the Authorized Keys File:
bash
1
icacls administrators_authorized_keys /inheritance:r /grant "Administrators:F" /grant "SYSTEM:F"
Modifies the permissions of the
administrators_authorized_keys
file. It removes inherited permissions and grants full control to theAdministrators
group and theSYSTEM
account.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.