Step 1: Generate KEY
- cd ~/.ssh
- ssh-keygen -t rsa -b 4096 -C "email@email.com"
NOTE -
Keys need to be only readable by you:
chmod 400 ~/.ssh/id_rsa
If Keys need to be read-writable by you:
chmod 600 ~/.ssh/id_rsa
Step 2: Check the Contents and copy
- cat ~/.ssh/nameOfFile.pub | pbcopy
Step 3: Configure your SSH key into Bitbucket.org (similar applies to Github.com)
GOTO settings => SSHKEY
- Add what you copied in Step 2 and give it a name
Step 4: Clone your repository using SSH protocol
- git clone git@bitbucket.org:{username}/repo.git
- git clone git@github.com:{username}/repo.git
This should work BUT
If you keep getting this error
[
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
]
Follow this steps.
i. ssh -T hg@bitbucket.org OR ssh -T hg@github.com depending on which you are using { This will attempt to create a connection to Bitbucket OR Github Cloud ).
ii. If you do not see a message similar to (logged in as username.). Go to the next step
iii. ssh-add ~/.ssh/identity (identity is whatever name you saved the file when generating a key)
iv. You will get this message (Identity added: /path to ssh file/.ssh/mywork (youremail@email.com)
v. You can now clone your repository.