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.
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.
3. Copy the public key.
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.
ssh -T email@example.com
ssh -T firstname.lastname@example.org
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.
git clone email@example.com:devopscube/example.git
That’s it. Now you will be able to push to your repository without username or password.