Access GIT Using SSH Key
Categories:
less than a minute
Create SSH Key
Create a SSH (private/public) key using the following command
ssh-keygen -t rsa -C "somerefname"
The above command asks for phase phrase and either enter the pass phrase or press enter for no pass phrase.
The above command generates following two files in your «home»/.ssh directory
- id_rsa
- id_rsa.pub
Login to your GIT hosting server (e.g. github.com or bitbucket.org) and import the public key into your profile.
Import Key
Import public key into Bitbucket.org
- Click your profile icon in the top right corner
- Click “Bitbucket Settings”
- Click “SSH Keys”
- Click “Add Key”
- Enter the “label” as you wish to identify the SSH key
- Copy the content of id_rsa.pub and paste it in “Key”
- Click “Add Key” button
Checkout using SSH Url
Checkout the repository using the SSH url
e.g. ssh://git@bitbucket.org/myteam/myrepo.git
OR
git@bitbucket.org:myteam/myrepo.git
Ref: