Before adding a new SSH key to your GitHub account, you should have:

After adding a new SSH key to your GitHub account, you can reconfigure any local repositories to use SSH. For more information, see “Switching remote URLs from HTTPS to SSH.”
Note: DSA keys (SSH-DSS) are no longer supported. Existing keys will continue to function, but you cannot add new DSA keys to your GitHub account.

  1. Copy the SSH key to your clipboard.
    If your SSH key file has a different name than the example code, modify the filename to match your current setup. When copying your key, don’t add any newlines or whitespace.

    1. $ clip < ~/.ssh/id_rsa.pub
    2. # Copies the contents of the id_rsa.pub file to your clipboard
  2. Tip: If clip isn’t working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

  3. In the upper-right corner of any page, click your profile photo, then click Settings.
    Adding a new SSH key to your GitHub account - 图1
  4. In the user settings sidebar, click SSH and GPG keys.
    Adding a new SSH key to your GitHub account - 图2
  5. Click New SSH key or Add SSH key.
    Adding a new SSH key to your GitHub account - 图3
  6. 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”.
  7. Paste your key into the “Key” field.
    Adding a new SSH key to your GitHub account - 图4
  8. Click Add SSH key.
    Adding a new SSH key to your GitHub account - 图5
  9. If prompted, confirm your GitHub password.
    Adding a new SSH key to your GitHub account - 图6

    Further reading