About addition of SSH keys to your account
You can access and write data in repositories on GitHub.com using SSH (Secure Shell Protocol). When you connect via SSH, you authenticate using a private key file on your local machine. For more information, see “About SSH.”
You can also use SSH to sign commits and tags. For more information about commit signing, see “About commit signature verification.”
After you generate an SSH key pair, you must add the public key to GitHub.com to enable SSH access for your account.
Before adding a new SSH key to your account on GitHub.com, complete the following steps.
- Check for existing SSH keys. For more information, see “Checking for existing SSH keys.”
- 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 GitHub.com, you can reconfigure any local repositories to use SSH. For more information, see “Switching remote URLs from HTTPS to SSH.”
Note: GitHub improved security by dropping older, insecure key types on March 15, 2022.
As of that date, DSA keys (
ssh-dss) are no longer supported. You cannot add new DSA keys to your personal account on GitHub.com.
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.
- 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 clipboardTip: If
clipisn’t working, you can locate the hidden
.sshfolder, open the file in your favorite text editor, and copy it to your clipboard.
- In the upper-right corner of any page, click your profile photo, then click Settings.
- In the “Access” section of the sidebar, click SSH and GPG keys.
- Click New SSH key or Add SSH key.
- 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”.
- Select the type of key, either authentication or signing. For more information about commit signing, see “About commit signature verification.”
- Paste your key into the “Key” field.
- Click Add SSH key.
- If prompted, confirm access to your account on GitHub. For more information, see “Sudo mode.”