Tuesday, June 21, 2016

Setting up git on window machine

I am trying to setup git on my windows machine and trying to connect to bitbucket.org to access repository.

When I am testing the connection I am getting the error


harvey@HARVEY-L MINGW64 /d/HarveyGitTest (master)
$ ssh -T git@bitbucket.org
Warning: Permanently added the RSA host key for IP address '104.192.143.2' to the list of known hosts.
Permission denied (publickey).

harvey@HARVEY-L MINGW64 /d/HarveyGitTest (master)

What is going on here ?

I will give you a background before I move ahead. I have installed 64bit git client for windows and using its command line.

The command line opens using Git Bash utility.

The problem is that I need to add my local public key on to bitbucket.

1. Generating ssh key pair

Open another session of Git Bash and

cd .ssh

see if you can find id_rsa and id_rsa.pub file.

id_rsa -->> This file if exists contains my private key
id_rsa.pub -->> This file if exists contains my public key

In case the files do not exist then generate them using command

ssh-keygen -t rsa

and then follow the prompts. Now you would be able to see both of these files id_rsa and id_rsa.pub.

Now get the contents of id_rsa.pub using

cat id_rsa.pub

copy the contents and then go to bitbucket.org

On right side click on your icon >> View Profile.

you will see a button "Bitbucket Settings" under there on the page, click it.

One the left side click on SSH Keys >> Add Key

Enter Label and paste the key and click Add Key to save it.

Now go back to Git Bash where you were getting the error and run the command below:

 ssh -T git@bitbucket.org

harvey@HARVEY-L MINGW64 /d/HarveyGitTest (master)
$ ssh -T git@bitbucket.org
logged in as harv.

You can use git or hg to connect to Bitbucket. Shell access is disabled.

harvey@HARVEY-L MINGW64 /d/HarveyGitTest (master)

Enjoy!!!



No comments: