I have the public key. I think this is needed for the SSH connection to the server where the git repo is located.
Now I don't know how to get the code. Can someone please tell me the complete procedure that I have to do so I get the code?
- Installing git + related configuration
- Establish SSH connection
- Get the repo
2 Answers
Setup Git
Implement SSH on GitHub/BitBucket
- Generate the SSH key with
ssh-keygen -t rsa -b 4096(see here) - Copy the content of your public SSH key, it is the file
id_rsa.pubby default - Paste the content into your GitHub/BitBucket account on the SSH key section
Get the repo
Just clone it:
- GitHub:
git clone :YOUR_USERNAME/REPO_NAME.git - BitBucket:
git clone :USERNAME/REPO_NAME.git
For more information managing a repo, take a look at the Git For Humans guide by Lucio Martinez.
GUI Tools
You can install git-gui which is a built-in GUI tool for commit.
For more options, take a look at the list on the official page.
3Step 1: Generate KEY
- cd ~/.ssh
- ssh-keygen -t rsa -b 4096 -C ""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 | pbcopyStep 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 nameStep 4: Clone your repository using SSH protocol
- git clone :{username}/repo.git
- git clone :{username}/repo.gitThis 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 OR ssh -T 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 ()
v. You can now clone your repository.