Primary Navigation

Using SSH to authenticate with your repositories

SSH is an fast & secure way to communicate with your Git & Mercurial repositories in Codebase. When you choose to use SSH, all your traffic is encrypted and your are authenticated using your own set of SSH keys.

Understanding SSH keys

An SSH keypair consists of a public and a private key. These are generated on your computer and you just need to send us the public key. The private key is kept on your computer and should never be sent to anyone else.

To generate a new key pair, just open up your terminal of choice and run ssh-keygen. You'll be guided through a number of steps which will help you create your key. The defaults are fine if this is your first time creating a new key. When asked to add a passphrase, it's strongly recommended to protect your key with a passphrase in case you lose it.

Once you've got this key, just head over to your Codebase account. Select Settings and then My Profile from the menu in the top right. Then you can select Add new SSH public key and paste your newly generated public key into this field.

Pushing/pulling your code

Pushing & pulling your repositories happens in exactly the same way as when you use HTTP. Any SSH repository URLs will look like this:

git@codebasehq.com:your-account/project-name/repo-name.git

To clone your repository, just enter your usual clone command followed by your SSH URL. You can find your SSH transport URL on any repository page in the Codebase interface.

Converting a repository from HTTP to SSH

If you've already got a repository which uses HTTP, you can easily switch to SSH using the command below.

Check that you're SSH client is using the correct private key for the request. You can do this by running the command below and examining the output. It should list all the SSH keys which are being provided. If you don't see your key, you may need to run ssh-add.

$ git clone git@codebasehq.com:viaduct/viaduct/app.git test# Cloning into 'test'...# Error: You do not have access to this repository.

This means that your key was sent successfully but you do not have access to the repository which you have requested.

Ensure that you have entered the URL to the repository correctly.

Check that you have access to the repository in the web interface.

Check with the account owner to ensure that you should have access.

Summary

We hope you've found this guide helpful in outlining how to set up SSH authentication to our Codebase repositories. If you have any questions about this or any other aspect of Codebase, please don't hesitate to get in touch.

Tell us how you feel about this post?

0

2

0

0

1

Enjoy this? Please help us by sharing it…

A little bit about the author

Adam is the managing director at aTech Media. A software developer & designer by trade specialising in Ruby & Rails - with over 130 open source repos. When not computer-ing, Adam enjoys a bit of baking, Formula 1 and playing FlightSim.