Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up SSH keys for Bitbucket on Windows

First, I am an absolute noob with git, repos and command line. I have repo on Bitbucket and I basically want to be able to push to the repository via gitbash without entering a password each time.

What I have:

  • A repository on Bitbucket with the code already set up.
  • A local directory where the repository is cloned.
  • A public key and a private key generated via PuTTY.
  • Public key added to Bitbucket via the Manage SSH keys page.

How do I now make it work so that I don't have to enter the password each time I push from the gitbash terminal? I'm using Windows 10.

like image 941
Sujan Sundareswaran Avatar asked Apr 23 '16 15:04

Sujan Sundareswaran


People also ask

How do I link my SSH key to Bitbucket?

Add the public key to your repository From Bitbucket, go to the repository and click Repository settings. Click Access keys from the left menu. Press Add key. From the Add SSH key dialog, enter a Label and paste the public key from the clipboard.

Where do I put SSH keys in Windows?

The contents of your public key (\. ssh\id_ed25519. pub) needs to be placed on the server into a text file called authorized_keys in C:\Users\username\. ssh\.

Can you use SSH keys on Windows?

Recent versions of Windows 10 include OpenSSH client commands to create and use SSH keys and make SSH connections from PowerShell or a command prompt.


2 Answers

Please follow the steps to add ssh key into bitbucket account to solve your issue.

  1. Open git bash terminal and enter the command ssh-keygen -t rsa -C "your email address"
  2. Enter passphrase (leave it blank) and enter
  3. Enter the same phrase again (leave it blank) and enter
  4. Copy the id_rsa.pub file content from where it is residing in your system (C:\Users\username\.ssh)
  5. 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!

like image 115
Rajesh Kumar Avatar answered Sep 19 '22 15:09

Rajesh Kumar


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.

like image 38
Andrew Avatar answered Sep 19 '22 15:09

Andrew