Aug 20, 2020 Win32 port of OpenSSH. Contribute to PowerShell/Win32-OpenSSH development by creating an account on GitHub. OpenSSH is the open-source version of the Secure Shell (SSH) tools used by administrators of Linux and other non-Windows for cross-platform management of remote systems. OpenSSH has been added to Windows as of autumn 2018, and is included in Windows 10 and Windows Server 2019.
Table Of Contents
- When to use SSH keys instead of HTTPS
Github Openssh Password
Pre-requisites
- Git Bash
When to use SSH keys instead of HTTPS
- Your corporate firewall blocks port 22, then even if you have set the remote origin to use HTTPS url, the authentication will fail as it is done via SSH.
Remedy is to set up SSH keys and use SSH over HTTPS port 443.
Below are some of the errors different applications throw when the port is blocked and HTTPS remote url is used.
Git Bash
When you try to push your changes, both Github Login
and OpenSSH
prompt asking for your username and password will fail with error remote no anonymous write access. fatal authentication failed for github
.
Github Desktop Application
You will be able to login to your github desktop application as the authentication is done via HTTPS. However, when you try to push your changes it will result in authentication failure.
Below is the logs captured by the desktop application showing that the git push is trying to authenticate via SSH.
Generate new SSH key
Run Git Bash.
Generate SSH key with your email id as comment.
When you’re prompted to “Enter a file in which to save the key,” press Enter to save the key in the default location (/c/Users/username/.ssh/id_rsa). Your public key will also get saved here.
Copy the public key to clipboard.
Add public SSH key to your GitHub account
Go to Settings
in your Github account to add the SSH public key.
Under SSH keys
tab, select New SSH key
.
Give a title and paste the key in the text area.
Add private SSH key to the ssh-agent
Git bash tool comes with a ssh-agent.
Create a new ~/.profile
(or) ~/.bashrc
file by running below command in git bash.
Paste below script into your ~/.profile
(or) ~/.bashrc
file to auto launch the ssh-agent whenever you run your git bash shell.
This script will load the identities in the ssh agent from your default location ~/.ssh/id_rsa
.
Use SSH over HTTPS
This step is required only if your corporate firewall is blocking port 22.
Create a new config file in your .ssh
directory i.e. /c/Users/username/.ssh/config
Paste below contents in the file to use port 443 for SSH connections to host ssh.github.com
.
Run below command in git bash to verify that the configuration is working. Ignore any authentication failures.
You can see that the SSH connection is now established via port 443.
Verification
To check if everything works as expected perform below steps:
Run new git bash shell.
Check if the identity has been added to the ssh agent.
- Check that the key is being used by trying to connect to git@github.com.
Github Openssh Server
- Clone the repo using the SSH url.
Openssh Github Windows
Going forward, every push/pull will use the SSH keys to authenticate with Github.