SSH keys provide secure authentication for GitHub repositories without requiring your username and password each time you push or pull code. The key acts as a unique digital credential tied to your machine.
You will generate an SSH key pair on your local device and add the public portion to your GitHub account. Once configured, you can interact with your repositories from the command line without entering credentials.
You will create a new SSH key pair on your local machine. This generates two files: a private key that stays on your device and a public key that you share with GitHub.
First, check whether you already have an SSH key:
ssh-add -l
If this command lists an existing key, you can use that key with GitHub. If no key exists, follow these steps to create one:
name@domain.tld with your email address. This creates a 4096-bit RSA key, which provides strong security for GitHub authentication.ssh-keygen -t rsa -b 4096 -C "name@domain.tld"
~/.ssh/id_rsa, which is the standard location SSH clients check automatically.cat ~/.ssh/id_rsa.pub
Copy the entire output, starting with ssh-rsa and ending with your email address. Never share your private key file (id_rsa) with anyone or commit it to a repository.
You will now add your public key to your GitHub account. This allows GitHub to recognise your machine when you connect via SSH.
github.com. Sign in to your account.Test your connection by running this command in your terminal:
ssh -T git@github.com
If successful, you will see a message confirming authentication. You can now clone repositories using SSH URLs and push changes without entering your GitHub credentials.
Your machine now authenticates with GitHub using SSH keys. You generated a key pair, added the public key to your GitHub account and tested the connection. You can now work with repositories from the command line without entering your username and password.
Review our guide on connecting and using SSH for more information about SSH authentication. If you manage repositories on your hosting account, learn how to set up Git version control in cPanel.
Create isolated individual accounts for your clients and manage them all from one dashboard.
Get Reseller HostingUpgrade to VPS hosting for scalable resources and root access to your server.
Get VPS Hosting