Setting up SSH keys for Bitbucket on Windows
There are two ways to load a remote git repository: using SSH and using HTTPS.
SSH will use a key pair, and requires the public key to be added to your BitBucket/GitHub profile.
HTTPS requires your BitBucket/GitHub username and password. You will be promoted for your password every time you interact with the remote server (clone, fetch, push, pull).
If you are currently being prompted for a password, that means the remote URL is currently set to use HTTPS. You can determine this be running git remote -v
. To change to use SSH, you need to update the remote URL to the SSH URL by running git remote set-url <remote alias> <SSH URL>
. If you only have one remote server, <remote alias>
will be origin
. You can find the SSH URL in BitBucket/GitHub under the clone option of the repository.
Please follow the steps to add ssh key into bitbucket account to solve your issue.
- Open git bash terminal and enter the command ssh-keygen -t rsa -C "your email address"
- Enter passphrase (leave it blank) and enter
- Enter the same phrase again (leave it blank) and enter
- Copy the id_rsa.pub file content from where it is residing in your system (C:\Users\username\.ssh)
- Login to bitbucket account and click top right most user icon ->bitbucket settings->ssh keys under security menu then paste into key field and save it. 6.Restart your git bash terminal and enter git init command and add ssh git repository location [email protected]:username/repository_name.git which is present in your bitbucket repository.
Enjoy!
1) create .ssh folder under your home directory like:
mkdir C:\Users\USERNAME\.ssh
2) Copy id_rsa and id_rsa.pub into directory from previous step
3) Close and open cmd (console window)
4) You need to clone the repository as SSH repository, like:
git clone ssh://[email protected]:USERNAME/repository.git
Then it should work.