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
  • When you establish a SSH connection, it is going to be independent for every server. You should mention what sort of server are you using. For instance, GitHub, BitBucket or a private one.
    – Lucio
    Sep 23, 2014 at 16:46
  • @Lucio it is a private one, what do I have to do with the SSH then? Sep 23, 2014 at 16:54
  • The procedure in your side (generate the key) is the same. The procedure of deploying your key on the server is what will be different. For that, you will need to ask for help to the server admin.
    – Lucio
    Sep 23, 2014 at 18:49

2 Answers 2


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:

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.

  • thanks Lucio; in your guide you have the assumption that I use GitHub or BitBucket, instead the repo is located at git@git.<somewebsite.net>:<reponame> does this change anything? Sep 23, 2014 at 16:52
  • 1
    Not really, just make sure to mention correctly your server.
    – Lucio
    Sep 23, 2014 at 18:47
  • if you want to switch remote URL from HTTPS to SSH Jul 23, 2019 at 1:21

Step 1: Generate KEY

- cd   ~/.ssh

- ssh-keygen -t rsa -b 4096 -C "[email protected]"

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 [email protected]:{username}/repo.git

- git clone [email protected]:{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 [email protected] OR ssh -T [email protected] 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 ([email protected])
v. You can now clone your repository.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .