This guide walks you through changing your Git authentication method from HTTPS to SSH. Using SSH eliminates the need to enter a password each time you interact with a remote repository.
Before proceeding, ensure you have SSH keys set up. If you haven’t done this yet, check out my guide on setting up SSH keys in Ubuntu WSL.
Contents:
1. Check Current Git Remote URL
2. Change Git from HTTPS to SSH
3. Test the Connection
Steps to Change Git Authentication from HTTPS to SSH
Check Your Current Git Remote URL
If your repository is not already cloned, we use the following command to clone it via HTTPS:
# Clone repo using HTTPS git clone https://your-repo-url.git

Now, let’s check the current Git remote URL:
# Check the remote Git URL git remote get-url origin

If the returned URL starts with https://
, it confirms that your repository is using HTTPS authentication.
Change Git from HTTPS to SSH
Switching to SSH authentication allows more seamless interactions with Git repos without having the repeated password prompts.
Step 1: Retrieve the SSH URL
Head over to your repository hosting service (e.g., GitHub, GitLab, Bitbucket) and locate the SSH URL for your repository. For this demo I’m using Bitbucket. It’s all more or less the same, and you should be able to find the similar drop-down menu below.
Step 2: Navigate to your Git repository link and select SSH

Step 3: Update the Git Remote URL
Run the following commands to update the remote URL from HTTPS to SSH, and to confirm that the remote URL has been updated successfully:
# Set remote URL to SSH git remote set-url origin git@your-repo-provider.com:your-repo.git # Check the updated remote Git URL git remote get-url origin

The output should now start with git@
, indicating that SSH authentication is in use.
Test the Connection
To ensure everything is working correctly, try fetching the latest changes from your repository:
# Test SSH connection git fetch
If no authentication prompts appear and the command executes successfully, your Git repository is now using SSH authentication!
Conclusion
Switching from HTTPS to SSH authentication in Git improves security and streamlines the workflow by eliminating repeated password prompts. Once configured, SSH makes managing repositories easier. If you need help setting up SSH keys, refer to my detailed guide on setting up SSH on Ubuntu WSL.
For more random tips on using Git (mostly on Windows), check out my blog tag Git Commands!