Adding a new SSH key to your GitHub account

To configure your GitHub account to use your new (or existing) SSH key, you'll also need to add it to your GitHub account.

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: GitHub is improving security by dropping older, insecure key types.

DSA keys (ssh-dss) are no longer supported. Existing keys will continue to function through March 15, 2022. You cannot add new DSA keys to your user account on GitHub.

RSA keys (ssh-rsa) with a valid_after before November 2, 2021 may continue to use any signature algorithm. RSA keys generated after that date must use a SHA-2 signature algorithm. Some older clients may need to be upgraded in order to use SHA-2 signatures.

  1. Copy the SSH public key to your clipboard.

    If your SSH public 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.

    $ pbcopy < ~/.ssh/id_ed25519.pub
    # Copies the contents of the id_ed25519.pub file to your clipboard

    Tip: If pbcopy isn't working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

  2. In the upper-right corner of any page, click your profile photo, then click Settings. Settings icon in the user bar

  3. In the user settings sidebar, click SSH and GPG keys. Authentication keys

  4. Click New SSH key or Add SSH key. SSH Key button

  5. 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".

  6. Paste your key into the "Key" field. The key field

  7. Click Add SSH key. The Add key button

  8. If prompted, confirm your GitHub password. Sudo mode dialog

  1. Copy the SSH public key to your clipboard.

    If your SSH public 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.

    $ clip < ~/.ssh/id_ed25519.pub
    # Copies the contents of the id_ed25519.pub file to your clipboard

    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.

  2. In the upper-right corner of any page, click your profile photo, then click Settings. Settings icon in the user bar

  3. In the user settings sidebar, click SSH and GPG keys. Authentication keys

  4. Click New SSH key or Add SSH key. SSH Key button

  5. 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".

  6. Paste your key into the "Key" field. The key field

  7. Click Add SSH key. The Add key button

  8. If prompted, confirm your GitHub password. Sudo mode dialog

  1. Copy the SSH public key to your clipboard.

    If your SSH public 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.

    $ sudo apt-get update
    $ sudo apt-get install xclip
    # Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)
    
    $ xclip -selection clipboard < ~/.ssh/id_ed25519.pub
    # Copies the contents of the id_ed25519.pub file to your clipboard

    Tip: If xclip isn't working, you can locate the hidden .ssh folder, open the file in your favorite text editor, and copy it to your clipboard.

  2. In the upper-right corner of any page, click your profile photo, then click Settings. Settings icon in the user bar

  3. In the user settings sidebar, click SSH and GPG keys. Authentication keys

  4. Click New SSH key or Add SSH key. SSH Key button

  5. 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".

  6. Paste your key into the "Key" field. The key field

  7. Click Add SSH key. The Add key button

  8. If prompted, confirm your GitHub password. Sudo mode dialog

To learn more about GitHub CLI, see "About GitHub CLI."

To add an SSH key to your GitHub account, use the ssh-key add subcommand, specifying your public key.

gh ssh-key add key-file

To include a title for the new key, use the -t or --title flag.

gh ssh-key add key-file --title "personal laptop"

Further reading

Did this doc help you?Privacy policy

Help us make these docs great!

All GitHub docs are open source. See something that's wrong or unclear? Submit a pull request.

Make a contribution

Or, learn how to contribute.