89 lines
4.4 KiB
Markdown
89 lines
4.4 KiB
Markdown
---
|
|
title: Adding a new SSH key to your GitHub account
|
|
intro: '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.'
|
|
redirect_from:
|
|
- /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
|
|
versions:
|
|
fpt: '*'
|
|
ghes: '*'
|
|
ghae: '*'
|
|
ghec: '*'
|
|
topics:
|
|
- SSH
|
|
shortTitle: Add a new SSH key
|
|
---
|
|
|
|
## About addition of SSH keys to your account
|
|
|
|
{% data reusables.ssh.about-ssh %} For more information, see "[AUTOTITLE](/authentication/connecting-to-github-with-ssh/about-ssh)."
|
|
|
|
{% ifversion ssh-commit-verification %}You can also use SSH to sign commits and tags. For more information about commit signing, see "[AUTOTITLE](/authentication/managing-commit-signature-verification/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 "[AUTOTITLE](/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys)."
|
|
1. Generate a new SSH key and add it to your machine's SSH agent. For more information, see "[AUTOTITLE](/authentication/connecting-to-github-with-ssh/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 "[AUTOTITLE](/get-started/getting-started-with-git/managing-remote-repositories#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 %}
|
|
1. Click **New SSH key** or **Add SSH key**.
|
|
1. 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 %}
|
|
1. Select the type of key, either authentication or signing. For more information about commit signing, see "[AUTOTITLE](/authentication/managing-commit-signature-verification/about-commit-signature-verification)."
|
|
{% endif %}
|
|
1. In the "Key" field, paste your public key.
|
|
1. Click **Add SSH key**.
|
|
{% 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`](https://cli.github.com/manual/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.
|
|
|
|
```shell
|
|
gh ssh-key add KEY-FILE
|
|
```
|
|
|
|
To include a title for the new key, use the `-t` or `--title` flag.
|
|
|
|
```shell
|
|
gh ssh-key add KEY-FILE --title "personal laptop"
|
|
```
|
|
|
|
If you generated your SSH key by following the instructions in "[AUTOTITLE](/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)", you can add the key to your account with this command.
|
|
|
|
```shell
|
|
gh ssh-key add ~/.ssh/id_ed25519.pub
|
|
```
|
|
|
|
{% endcli %}
|
|
|
|
{% ifversion fpt or ghec %}
|
|
|
|
## Further reading
|
|
|
|
- "[AUTOTITLE](/authentication/authenticating-with-saml-single-sign-on/authorizing-an-ssh-key-for-use-with-saml-single-sign-on)"
|
|
{% endif %}
|