5.6 KiB
title, intro, redirect_from, versions, topics
| title | intro | redirect_from | versions | topics | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Adding a new SSH key to your GitHub account | To configure your {% data variables.product.product_name %} account to use your new (or existing) SSH key, you'll also need to add it to your {% data variables.product.product_name %} account. |
|
|
|
Before adding a new SSH key to your {% data variables.product.product_name %} account, you should have:
After adding a new SSH key to your {% data variables.product.product_name %} account, you can reconfigure any local repositories to use SSH. For more information, see "Switching remote URLs from HTTPS to SSH."
{% data reusables.ssh.dsa-support %}
{% if currentVersion == "free-pro-team@latest" or currentVersion == "github-ae@latest" or currentVersion ver_gt "enterprise-server@2.19" %} {% tip %}
Tip: You can also add an SSH key using the {% data variables.product.prodname_cli %}. For more information, see "gh ssh-key add" in the {% data variables.product.prodname_cli %} documentation.
{% endtip %} {% endif %}
{% mac %}
- 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 %}
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.
{% endtip %}
{% data reusables.user_settings.access_settings %}
{% data reusables.user_settings.ssh %}
4. Click New SSH key or Add SSH key.
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.
7. Click Add SSH key.
{% data reusables.user_settings.sudo-mode-popup %}
{% endmac %}
{% windows %}
- 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 %}
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.
{% endtip %}
{% data reusables.user_settings.access_settings %}
{% data reusables.user_settings.ssh %}
4. Click New SSH key or Add SSH key.
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.
7. Click Add SSH key.
8. If prompted, confirm your {% data variables.product.product_name %} password.

{% endwindows %}
{% linux %}
- 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 %}
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.
{% endtip %}
{% data reusables.user_settings.access_settings %}
{% data reusables.user_settings.ssh %}
4. Click New SSH key or Add SSH key.
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.
7. Click Add SSH key.
8. If prompted, confirm your {% data variables.product.product_name %} password.

{% endlinux %}
{% if currentVersion == "free-pro-team@latest" %}
Further reading
- "Authorizing an SSH key for use with SAML single sign-on" {% endif %}