Using an SSH key with GitHub provides a secure and convenient way to connect to your repositories from the command line. Instead of entering your GitHub username and password every time you push or pull code, you can authenticate using your SSH key acting as a secure digital key unique to your machine.
This guide explains how to create an SSH key on your local device and how to upload the public portion of that key to your GitHub account. If you’ve already generated an SSH key, feel free to skip to the second section.
First, check whether you already have an SSH key:
ssh-add -l
If this command lists an existing key, you may not need to create a new one. Otherwise, follow the steps below:
Next, retrieve your new public key:
cat ~/.ssh/id_rsa.pub
Copy the output—this is your public SSH key, which you’ll upload to GitHub. Your SSH key has two parts:
Once your key is created, adding it to GitHub is straightforward:
Your machine is now linked to GitHub using SSH, allowing seamless and secure access when working with your repositories. Learn how to set up git version control on cPanel.