git ssh authentication

How to Create and Setup SSH Authentication for BItbucket and Github

I want to setup ssh authentication keys for my GitHub and Bitbucket account. So that I can commit to those repositories without username and password. How can I achieve this?

Solution: You can setup a passwordless authentication to your repositories on Github and Bitbucket using ssh keys. Follow the steps given in this article carefully to set it up.

Create a Key Pair

First, you need to create a key pair using OpenSLL utility.

1 .CD in to .ssh folder of your system.

cd ~/.ssh

2. Create a public and private key pair. When prompted for options, just press enter to select the default options. Optionally you can set a passphrase for your key.

t

3. Copy the public key.

cat id_rsa.pub

4. Head over to Github or Bitbucket settings page and in the ssh keys option, add the id_rsa.pub contents that you have copied.

5. Once you are done with adding the keys, you can test the ssh connection using the following commands. First time it will ask to accepts the fingerprint.

For bitbucket,

ssh -T [email protected]

For Github,

ssh -T [email protected]

Cloning Repo

An important thing to notice when cloning the repo is, you should clone the repo with ssh URL and not the https URL. If you clone with https URL, ssh authentication won’t happen and it will ask for username and password.

For example,

git clone [email protected]:devopscube/example.git

That’s it. Now you will be able to push to your repository without username or password.

Other Interesting Blogs

Leave a Comment

Share via
Copy link
Powered by Social Snap