We strongly recommend using an SSH connection when interacting with GitHub. SSH keys are a way to identify trusted computers, without involving passwords. The steps below will walk you through generating an SSH key and then adding the public key to your GitHub account.

Step 1: Check for SSH keys

First, we need to check for existing SSH keys on your computer. Open up the command line and type:

cd ~/.ssh ls -al # Lists the files in your .ssh directory 

Check the directory listing to see if you have files named either id_rsa.pub or id_dsa.pub. If you don't have either of those files go to step 2. Otherwise, you can skip to step 3.

Step 2: Generate a new SSH key

To generate a new SSH key, copy and paste the text below, making sure to substitute in your email. The default settings are preferred, so when you're asked to "enter a file in which to save the key,"" just press enter to continue.

ssh-keygen -t rsa -C "[email protected]" # Creates a new ssh key using the provided email # Generating public/private rsa key pair. # Enter file in which to save the key (/your_home_path/.ssh/id_rsa): 

Next, you'll be asked to enter a passphrase:

# Enter passphrase (empty for no passphrase): [Type a passphrase] # Enter same passphrase again: [Type passphrase again] 

Which should give you something like this:

# Your identification has been saved in /your_home_path/.ssh/id_rsa. # Your public key has been saved in /your_home_path/.ssh/id_rsa.pub. # The key fingerprint is: # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected] 

Why do passphrases matter?

Passwords aren't very secure. If you use one that's easy to remember, it's easier to guess or brute-force (try many options until one works). If you use one that's random, it's hard to remember, and thus you're more inclined to write it down. Both of these are Very Bad Things™.

This is why you're using SSH keys. But, using a key without a passphrase is basically the same as writing down that random password. Anyone who gains access to your computer has gained access to every system you use that key with. This is also a Very Bad Thing™. The solution is to add a passphrase to the SSH key, for an extra layer of security.

But I don't want to enter a long passphrase every time I use the key!

Neither do we! Thankfully, there's a nifty little tool called ssh-agent that can securely save your passphrase so you don't have to re-enter it. Depending on your OS, ssh-agent may be automatically run for you when you log in.

For more information about SSH key passphrases, check out our help guide.

Then add your new key to the ssh-agent:

ssh-add ~/.ssh/id_rsa