On Window
Step 1: Ensure that you have installed Git for Windows.
If installed, you should be able to access the Git Bash Shell from the starting menu
Step 2: Create your SSH keys
If you’ve already created SSH keys on your system, skip this step
Before creating the SSH key, check your ~/.ssh folder (for example C:\Users\dev\.ssh) and look for the following file:
On your git bash shell, create the SSH key using the command (for example ssh-keygen -C “dev@simiyu.me”) use to create your SSH key
Never share the contents of your private key. If the private key is compromised, attackers can use it to trick servers into thinking the connection is coming from you.
Step 3: Add public key to Azure DevOps
- Open your security settings by browsing to the web portal and selecting your avatar in the upper right of the user interface. Select SSH public keys in the menu that appears.
2. Select Add
3. Copy the contents of the public key (for example, id_rsa.pub) that you generated into the Public Key Data field.
4. Give the key a useful description (this description is displayed on the SSH public keys page for your profile) so that you can remember it later. Select Save to store the public key. Once saved, you can’t change the key. You can delete the key or create a new entry for another key. There are no restrictions on how many keys you can add to your user profile. Also note that SSH keys stored in Azure DevOps expire after one year. If your key expires, you may upload a new key or the same one to continue accessing Azure DevOps via SSH.
5. Test the connection by running the following command: ssh -T git@ssh.dev.azure.com. If everything is working correctly, you’ll receive a response that says: remote: Shell access is not supported.
Step 3: Clone the Git repository with SSH
To connect with SSH from an existing cloned repo
git remote set-url origin git@ssh.dev.azure.com:v3/fabrikam-fiber/FabrikamFiber/FabrikamFiber
For new repos
Copy the SSH clone URL from the web portal. In this example, the SSH clone URL is for a repo in an organization named fabrikam-fiber, as indicated by the first part of the URL after dev.azure.com.
Run the Git clone command
git clone git@ssh.dev.azure.com:v3/fabrikam-fiber/FabrikamFiber/FabrikamFiber
SSH may display the server’s SSH fingerprint and ask you to verify it. Verify that the displayed fingerprint matches one of the fingerprints in the SSH public keys page.
SSH displays this fingerprint when it connects to an unknown host to protect you from man-in-the-middle attacks. Once you accept the host’s fingerprint, SSH won’t prompt you again unless the fingerprint changes.
When you’re asked if you want to continue connecting, enter yes. Git clones the repo and sets up the origin remote to connect with SSH for future Git commands.
Please refer to the documentation on the reference section below for further clarification and questions.
Reference
https://learn.microsoft.com/en-us/azure/devops/repos/git/use-ssh-keys-to-authenticate?view=azure-devops