We quite often need to generate an SSH key on a remote environment, so open terminal and lets create a key.
I'm assuming that you've logged in to the server via SSH.
1. Check for existing keys
$ cd ~/.ssh $ ls
If you have either a id_rsa.pub or id_dsa.pub and know the password then great skip to step 3.
2. Create a new key
Create a new ssh key using your email as a label
$ ssh-keygen -t rsa -C "firstname.lastname@example.org"
You'll then receive a prompt:
$ Enter file in which to save the key (/Users/name/.ssh/id_rsa): [Press enter]
This is asking where you should save the key. Just use the default by hitting enter.
You'll next be asked for password and confirmation of that password:
$ Enter passphrase (empty for no passphrase): $ Enter same passphrase again:
Your key has now been created.
3. Copy the key to your clipboard
Now you need to grab the contents of that key to use elsewhere.
$ vi /Users/name/.ssh/id_rsa.pub
This will open your key in Vim, just copy the conetnts and you're done!