1
0
mirror of synced 2025-12-19 18:10:59 -05:00
Files
docs/content/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account.md
Joe Clark 74a679dc51 Make product variables for Enterprise translation-friendly (#31628)
Co-authored-by: Laura Coursen <lecoursen@github.com>
Co-authored-by: Evan Bonsignori <ebonsignori@github.com>
2022-10-17 18:54:05 +00:00

5.0 KiB

title, intro, redirect_from, versions, topics, shortTitle
title intro redirect_from versions topics shortTitle
Adding a new SSH key to your GitHub account To configure your account on {% ifversion ghae %}{% data variables.product.product_name %}{% else %}{% data variables.location.product_location %}{% endif %} to use your new (or existing) SSH key, you'll also need to add the key to your account.
/articles/adding-a-new-ssh-key-to-your-github-account
/github/authenticating-to-github/adding-a-new-ssh-key-to-your-github-account
/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account
fpt ghes ghae ghec
* * * *
SSH
Add a new SSH key

About addition of SSH keys to your account

{% data reusables.ssh.about-ssh %} For more information, see "About SSH."

{% ifversion ssh-commit-verification %}You can also use SSH to sign commits and tags. For more information about commit signing, see "About commit signature verification."{% endif %}

After you generate an SSH key pair, you must add the public key to {% ifversion fpt or ghec or ghes %}{% data variables.location.product_location %}{% elsif ghae %}{% data variables.product.product_name %}{% endif %} to enable SSH access for your account.

Prerequisites

Before adding a new SSH key to your account on {% ifversion ghae %}{% data variables.product.product_name %}{% else %}{% data variables.location.product_location %}{% endif %}, complete the following steps.

  1. Check for existing SSH keys. For more information, see "Checking for existing SSH keys."
  2. Generate a new SSH key and add it to your machine's SSH agent. For more information, see "Generating a new SSH key and adding it to the ssh-agent."

Adding a new SSH key to your account

After adding a new SSH authentication key to your account on {% ifversion ghae %}{% data variables.product.product_name %}{% else %}{% data variables.location.product_location %}{% endif %}, you can reconfigure any local repositories to use SSH. For more information, see "Switching remote URLs from HTTPS to SSH."

{% data reusables.ssh.key-type-support %}

{% webui %}

{% data reusables.gpg.copy-ssh-public-key %} {% data reusables.user-settings.access_settings %} {% data reusables.user-settings.ssh %} 4. Click New SSH key or Add SSH key. {% ifversion ssh-commit-verification %} SSH Key button {% else %} SSH Key button {% endif %} 5. In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal laptop, you might call this key "Personal laptop". {% ifversion ssh-commit-verification %} 6. Select the type of key, either authentication or signing. For more information about commit signing, see "About commit signature verification." {% endif %} 7. Paste your key into the "Key" field. {% ifversion ssh-commit-verification %} The key field {% else %} The key field {% endif %} 8. Click Add SSH key. The Add key button {% data reusables.user-settings.sudo-mode-popup %}

{% endwebui %}

{% cli %}

{% data reusables.cli.cli-learn-more %}

Before you can use the {% data variables.product.prodname_cli %} to add an SSH key to your account, you must authenticate to the {% data variables.product.prodname_cli %}. For more information, see gh auth login in the {% data variables.product.prodname_cli %} documentation.

{% ifversion ssh-commit-verification %}At present, you can only use {% data variables.product.prodname_cli %} to add SSH authentication keys, you cannot add SSH signing keys.{% endif %}

To add an SSH authentication 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"

If you generated your SSH key by following the instructions in "Generating a new SSH key", you can add the key to your account with this command.

gh ssh-key add ~/.ssh/id_ed25519.pub

{% endcli %}

{% ifversion fpt or ghec %}

Further reading