Saturday, January 3, 2015

Tangled in SSH keys












How to setup SSH connection to your server and Bitbucket (or Github, Stash)


It might be a little confusing at the beginning of  your journey with SSH to fathom how and where to generate ssh keys meant for SSH connection with your server and bitbucket (or Github, Stash). It might be a little more troublesome as soon as you are required to connect your development machine to bitbucket and to gain ability to update your code from the server.

The diagram below should represent the connection I want to setup.


Figure 1: final connection scheme


The first step is to setup remote connection to your server

What you want to do to establish connection with your server is to generate the ssh keys on your client. Next you should move the public key to the remote server.

The diagram below should help you in better understanding basics on where the keys should be generated and moved to.





Figure 2: remote connection

In this step the 'client' is usually your local machine (or development machine) and your 'remote server' is simply the server you want to establish ssh connection with.

You should be able to generate ssh keys by following github or confluence documentation.

If you have some difficulties with authentication agent like me, see this post.



The second step is to setup the connection between dev environment and bitbucket.


The last two steps are very simple. You simply have to generate the ssh keys and add the public key to the Bitbucket though bitbucket gui. 

The third step, and the last one, is to setup the connection between your server and bitbucket.

If you look at Figure 2 the only change that happens between this step and the first step is that now your server is your 'client' and bitbucket becomes your 'remote server'.

To generate the ssh keys on your server you can either follow github and confluence documentation or you can try and use your hosting's panel. Some of the hosting (e.g. Godaddy) allow you to generate the keys using their gui.

As soon as you're done with that you should avoid confusion with where to generate, move, and use your ssh keys. 

What's next? From this point you can follow Jonathan Nicol post and begin work on CI. 


Reference:

https://confluence.atlassian.com/
https://help.github.com/articles/generating-ssh-keys/
http://jonathannicol.com/
http://unixhelp.ed.ac.uk/

No comments:

Post a Comment