Table of Contents
I am sure that anyone using Github or Bitbucket for his code would at some point want to use SSH to solve the issues of providing username & password each time he has to fetch/push code to the server.
Use of SSH would also be productive and of a great help to people who constantly deal with hosting or have a lot of interaction with an external server.
For some real serious app development I decided to shift back to Ubuntu. I had been using Windows for some time now and was running into issues while working with virtualmachines. So I chose to go back to Elementary OS a beautiful port of Ubuntu. The move was welcome but how was I to ensure that I was able to do all the remote server related activities from the linux machine especially since I had already configured many of them to use SSH keys that I had generated with Putty on Windows.
Of course I had an option to start anew and do every configuration from start, but I wanted to use my existing SSH keys so that this migration was quick and smooth. One more reason for me to go this route was, since Putty had a Linux port I was quite sure that if I ran into any trouble I would be able to find a solution.
I had thought that the existing keys would be working without any problems. I imported the .ssh folder which was in my home folder in Windows (mounted as a share) into my Linux home folder.
I then copied the
id_rsa ssh key from my existing configuration in Windows and entered it in my remote server. But it wouldn't work. The server rejected the key saying that the format was incorrect. The ssh key was not in the correct format. I had to read a lot to understand what they were and what all were different, why it was so and what had to be done to ensure that the keys could be reused.
The process is not very tedious once you understand the whole theory behind SSH. I also realized that Putty saves the .pub key in a slightly different format than other key generators.
Like all things geek, after reading about it I found that this too was all logical and reasonable and once you think it from the programmers point of view, so intuitive.
I had to take a slightly different approach since I was already logged on Linux, and was too lazy to go to Windows for just this small job. So ..
There were more than one way of creating and using SSH keys using various programs and commands, but the concept remained the same.
My SSH keys had been created by Putty in Windows and it adopted a different process for creation and authentication vis-a-vis OpenSSH or other such programs. Also, the SSH keys created by Linux were more easily acceptable in all servers as compared to the Putty ones. The link from stackoverflow that helped me to understand this whole thing is here. 
In order convert an existing key all you had to do was to convert the Putty version keys to the version you wanted using PuttyGen, which got installed when we installed Putty, like OpenSSH or ssh.com.
This was perhaps the best method to do, but since I was in Linux.... I will tell you what I did. I will also keep the original links to the articles, that got me to understand this stuff, at the bottom of the page so that you can understand too.
Not going into too much of the jargon, I used the following command to convert my public key to the correct format. One can learn more from the link provided or the source from where the link originates.
sh-keygen -i -f keyfile.pub > newkeyfile.pub
Once I had done that, I cut pasted the contents of the new file into the SSH keys inside Github or Bitbucket and viola.
As an aside there is another cool thing that I learnt in this process; MacOS has a cool feature called
pbpaste that allows to send the contents of any file to the system clipboard from the command line. This can be used later to paste in any document or form over the internet.
This is how we do that in Ubuntu 
In Ubuntu(or any Linux distro with Xwindows), you can use
xsel. I like to make this alias
alias pbcopy='xclip -selection clipboard' alias pbpaste='xclip -selection clipboard -o'
or using xsel
alias pbcopy='xsel --clipboard --input' alias pbpaste='xsel --clipboard --output'
Now you can pipe any text to pbcopy
$ cat ~/.ssh/id_dsa.pub | pbcopy
$ pbcopy < ~/.ssh/id_dsa.pub
Your public ssh key is transferred to your clipboard and is ready to be pasted (perhaps with pbpaste).
If you wanted to understand about SSH and wanted to learn it from an authority, I can provide you with a link to the right place.