Skip to content

Instantly share code, notes, and snippets.

@askharley
Last active November 9, 2018 23:47
Show Gist options
  • Save askharley/2c659eb8ef883b1bbb19ed5e8a1eef1d to your computer and use it in GitHub Desktop.
Save askharley/2c659eb8ef883b1bbb19ed5e8a1eef1d to your computer and use it in GitHub Desktop.
SSH Keys

alt text

Setting up a SSH Key

What is a SSH Key?

SSH stands for Secure Shell. This is a cryptographic network protocol that's used for operating network services securely over an unsecured network. An SSH key is a way of connecting and authenticating yourself to networks.

Generating a SSH Key on macOS

  1. SSH keys can be generated through the terminal. The code below will begin the process.

ssh-keygen -t rsa

  1. The ssh-keygen utility prompts you to ask you where to store the key. Press ENTER to accept the default location.

  2. The ssh-keygen utility will then prompt you for a passphrase. I suggest using a passphrase as added security. You'll have to enter your passphrase twice.

  3. After the system generates your key pair, something like this will appear:

     Your identification has been saved in   /Users/myname/.ssh/id_rsa.
     Your public key has been saved in /Users/myname/.ssh/id_rsa.pub.
     The key fingerprint is:
     ae:89:72:0b:85:da:5a:f4:7c:1f:c2:43:fd:c6:44:38 myname@mymac.local
     The key's randomart image is:
     +--[ RSA 2048]----+
     |                 |
     |         .       |
     |        E .      |
     |   .   . o       |
     |  o . . S .      |
     | + + o . +       |
     |. + o = o +      |
     | o...o * o       |
     |.  oo.o .        | 
     +-----------------+
    
  4. You'll now have to navigate to the folder where the keys were created. The default will be .ssh. This folder will be hidden in your user folder. Locate your user folder and then press ⌘+⇧+. That is the shortcut to show all hidden folders and files.

  5. Inside .ssh are your keys. id_rsa is your private key and id_rsa.pub is the public key and this is what we need to use. Open this file up with your favourite text editor and copy it's contents.

Adding a SSH Key to Bitbucket

  1. Click on your icon in the top right and select Bitbucket settings

![alt text][bitbucket_settings]

alt text

  1. Click SSH keys under Security on the left

![alt text][ssh_keys]

alt text

  1. Give the key a label and the paste your key.

![alt text][add_key]

alt text

Congrats!

Awesome! You've officially setup a SSH key and got it working with Bitbucket. You can start contributing to society. This also means that you could get git-blamed for anything you mess up ;).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment