How to Add SSH Keys to Your GitHub Account Updated on February 5, 2025 by Jesse Owens 2 Minutes, 21 Seconds to Read GitHub offers a convenient SSH key feature for accessing your repositories on the command line. Instead of using usernames and passwords every time you push to or pull from your repository, you can use your key. In this article we’ll learn how to add SSH keys to your GitHub account. Why use an SSH key? Using an SSH key is a convenient and secure way to access your account. It’s convenient because you don’t need to remember a long password. And you can make your actual password so brutally long and secure that no human or bot could guess it. The SSH key works like an actual key that only you possess. How to Create an SSH Key In order to use an SSH key with Git, you must first create the key on your computer. If you already have an SSH key, you can skip these steps. In order to check if you have a key, you can run this command: user@server# ssh-add -l Follow along with the steps below to create the key and copy its contents. You will need to open your computer’s default terminal application. Open the terminal app on your computer. Enter the following command, substituting [email protected] with your email address: user@server# ssh-keygen -t rsa -b 4096 -C "[email protected]" Press Enter to accept the default file location. Enter a secure passphrase. Press Enter. Enter this command to display the contents of your public key: user@server# cat .ssh/id_rsa.pub Copy the contents of your key to your clipboard (we will need it later). It’s important to remember that the SSH key has two parts: a private key and a public key. As the name suggests, the private key is only for private use. Never ever share your private key with anyone (with exceptions made for your system administrator or other trusted people within your organization). This will be important later. How to Add an SSH Key to your Github Account Now we have already seen why you might want to use an SSH key. We also demonstrated how to create an SSH key on your computer. As mentioned above, we have a private key and a public key. In the steps below you’ll learn how to upload your public key to GitHub. Log into your GitHub account. Click your avatar and choose Settings. Select SSH and GPG keys. Click New SSH key. Enter a title in the field. Paste your public key into the Key field. Click Add SSH key. Next Steps Well done! You now know how to add SSH keys to your GitHub account. Make sure to check out some of our other Git articles: Introduction to Git Using Git to Publish Files How to Use Tags in Git Looking for a dedicated server? We’ve got you covered. Share this Article Related Articles SSH Commands: The Practical Guide for Developers and Site Owners How to Connect to Your Server with SSH How to Use SCP For Secure File Transfer A Complete SSH Tutorial for Beginners How to Connect to Your Server via SSH How to View MariaDB Databases Using the Command Line How to Add SSH Keys to Your GitHub Account How to Change Directories using SSH Commands How to SSH Into Your Shared/Reseller Server Viewing Running Processes on your Dedicated Server
Thank you! This works. So much more clear than GitHub’s site. Next issue… adding the key to ssh-agent
thanks for this guide! it was really helpful for me, with simple instructions and even graphics to guide me through.
I am on window and try to do the same but instead of providing email address, while generating ssh, I gave my system Name but getting “Permission denied (publicKey) errror.
Hello Tapan – sorry for your issues with the Public key error. If you follow the directions in the article and use an email address are you getting the same error? The error generally occurs because the email address was incorrect. You can find out more specific information in this article regarding that error: https://docs.github.com/en/authentication/troubleshooting-ssh/error-permission-denied-publickey.
It all doesn’t work from when trying to display the contents of your public key using: cat .ssh/id_rsa.pub (you get to a brick wall as the git responds with: “cat: .ssh/id_rsa.pub: No such file or directory”) – Therefore I believe this guide has become out of date and not useful anymore as from May 2022.
Hi Adi, and sorry to hear that you’re having trouble adding your SSH key to your Github account. That type of error message would normally occur if the file is saved to a different location, or with a different filename. Certain OSs will download files to unexpected places or remove the filetype suffix at times, so please make sure the file as listed is in the correct directory and let me know if you’re still encountering the error. Hope that helps!
Can you please help? I tried it but GitHub says You must supply a key in OpenSSH public key format. How can I fix this. Thank you very much in advance!
Hi Will, sorry that you’re having difficulty setting up Git. First, I just wanted to double check that you’re using the public key file — it should end in .pub. If you are, and are still running in to trouble try using this command to generate a key: ssh-keygen -t ed25519 -C "[email protected]" Just be sure to replace the example email with the email you intend to use. That should provide you with a workable key file. I hope that helps!
I rarely give comment on web info. This one I am giving a five star. I am new to Git and Mac as well. I have spent hours and hours searching online but did not find a complete answer until I got to this web site. Thanks to the author who composed this page.
Thank you for the kind words, and it’s great to hear that you found the article so helpful. I made sure to tell the author for you!
I’m sorry to see that. We appreciate your feedback so that we can make improvements in our Support Center. Is there a particular step that was not working for you?
The article worked for me on GitHub. For those who may have problems, I’d suggest perhaps dropping the -b 4096 switch and adding the -o switch to force an updated OpenSSH format. ssh-keygen -o -t rsa -C “[email protected]” That should create an SSH key that will work on all platforms. You can find an article on creating an SSH Key by Stuart Burns in Techtarget.com (SearchIT operations) for more detail.