Generating SSH keys
Step 1: Check for SSH keys
1 | $ ls -al ~/.ssh |
Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:>
id_dsa.pub>
id_ecdsa.pub>
id_ed25519.pub>
id_rsa.pub
Step 2: Generate a new SSH key
- With Git Bash still open, copy and paste the text below. Make sure you substitute in your GitHub email address.
1 | $ ssh-keygen -t rsa -b 4096 -C "your_email@example.com" |
- We strongly suggest keeping the default settings as they are, so when you’re prompted to “Enter a file in which to save the key”, just press Enter to continue.
1 | Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] |
- You’ll be asked to enter a passphrase.
1 | Enter passphrase (empty for no passphrase): [Type a passphrase] |
- After you enter a passphrase, you’ll be given the fingerprint, or id, of your SSH key. It will look something like this:
1 | Your identification has been saved in /Users/you/.ssh/id_rsa. |
Step 3: Add your SSH key to your account
Copy the SSH key to your clipboard. If your key is named id_dsa.pub, id_ecdsa.pub or id_ed25519.pub, then change the filename below from id_rsa.pub to the one that matches your key:
1 | $ clip < ~/.ssh/id_rsa.pub |
Add the copied key to GitHub:
In the top right corner of any page, click
setting
.In the user settings sidebar, click SSH keys.
Click Add SSH key.
In the Title field, add a descriptive label for the new key. For example, if you’re using a personal Mac, you might call this key “Personal MacBook Air”.
Paste your key into the “Key” field.
Click Add key.
Confirm the action by entering your GitHub password.
Step 4: Test the connection
To make sure everything is working, you’ll now try to SSH into . When you do this, you will be asked to authenticate this action using your password, which is the SSH key passphrase you created earlier.
- Open Git Bash and enter:
1 | $ ssh -T git@github.com |
- You may see this warning:
1 | The authenticity of host 'github.com (207.97.227.239)' can't be established. |
- Verify the fingerprint in the message you see matches the following message, then type yes:
1 | Hi username! You've successfully authenticated, but GitHub does not |
- If the username in the message is yours, you’ve successfully set up your SSH key!