38

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?

  1. Installing git + related configuration
  2. Establish SSH connection
  3. Get the repo
Braiam
  • 69,112

2 Answers2

38

Setup Git

  1. Install it with sudo apt-get install git (see here)
  2. Configure Git (see here)

Implement SSH on GitHub/BitBucket

  1. Generate the SSH key with ssh-keygen -t rsa -b 4096 (see here)
  2. Copy the content of your public SSH key, it is the file id_rsa.pub by default
  3. Paste the content into your GitHub/BitBucket account on the SSH key section

Get the repo

Just clone it:

  • GitHub: git clone git@github.com:YOUR_USERNAME/REPO_NAME.git
  • BitBucket: git clone git@bitbucket.org: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.

Lucio
  • 19,191
  • 32
  • 112
  • 191
2

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.
Gerald
  • 21