Read on for a quick tutorial on how to generate an SSH pubkey using Mac OS X. This should work for just about any version of Mac OS X and be useful to create public keys for services like Codebase.
Go into the Utilities folder in your Applications folder and open Terminal.app.
When the prompt appears, enter ‘ssh-keygen’ and hit return. This will start the key generator.
The first question the key generator will ask is where to save the key to. Just hit return to save the key in it’s default location
Enter file in which to save the key (/Users/tristan/.ssh/id_rsa):
Next, enter a passphrase to secure your key. It will ask you to confirm your passphrase. You can leave this blank, requiring no passphrase, but it is recommended to secure your key. When you use a passphrase, the system will ask you for that passphrase whenever the key is used for the first time after you’ve logged into your computer.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Next, you’ll be told where your key was saved and where your public key was saved. Select and copy the public key path. You’ll need that in a second. The path should look something like /Users/tristan/.ssh/id_rsa.pub.
Your identification has been saved in /Users/tristan/.ssh/id_rsa
Your public key has been saved in /Users/tristan/.ssh/id_rsa.pub
The key fingerprint is:
Next, type ‘cat ’ into the terminal, paste the path to your public key, and hit return. This will output your public key which you can then use elsewhere (like on Codebase)
$ cat /Users/tristan/.ssh/id_rsa.pub
Once you’ve done this, your public key will be output and look similar to:
ssh-rsa U2FsdGVkX1+VGwbGhYieyuhW+H0QD85yK3/wPCQfiXHLRtGt00AttZH N3SdjKFxjK3LsZlBGsve+aX7urQF23LKDM5esPzS7zFo75qSo6XNwPQYcBbpiRH xbXOZ+fPLoKjqYWvDEWs+RNMGs7QkQv+Xt096V/di3j48wZyRSStTGWBkEPRceR WBB6tSbKd48QNdbsZK1LVkiepw8dWBQNI8wuIEiWDe/TKlHaWCSOftRwQijC/qz GIwzBW0MojOR6j4aJU/rWzijFGw== tristan@24-107-186-239
You can copy and paste this public key as needed, and it will always be stored at the path where you generated it at (usually /Users/yourusername/.ssh/). Just make sure you’re always and only using your public key (id_rsa.pub) and not the private key that was generated (id_rsa).