Posted under » Version Control updated on 4 December 2025
Before adding a new SSH key to your GitHub account, you should have already generated a new SSH key and adding it to the ssh-agent.
First download your key file located at your ssh folder eg. ~/.ssh/id_ed25519.pub
Go to github using browser. In the upper-right corner of any page, click your profile photo, then click Settings.
In the user settings sidebar, click SSH and GPG keys.
Click New SSH key or Add SSH key.
Click Add SSH key. If prompted, confirm your GitHub password.
$ ssh-add ~/.ssh/id_ed25519.pub
Sometimes you may have different repos so you will have several keys. To let SSH know which key to look for, you need to specify at the config file ~/.ssh/config. For example
Host github HostName github.com User AdLe IdentityFile /home/ubuntu/.ssh/github.pub IdentitiesOnly yes
To check if the config works.
$ ssh-add ~/.ssh/id_ed25519.pub $ ssh -T git@github.com
If the connection is successful, you should see a message like, "Hi anoneh! You've successfully authenticated, but GitHub does not provide shell access." This confirms that your SSH key is set up correctly and that you can clone repositories. To clone a branch ..
$ git clone --branch revamp git@github.com:dajjal/adlsv3.git
As of 2024, github no longer accept plain clear password. So the SSH keys is one way to push.
You can also use tokens. To make things simple, choose the Personal access tokens (classic). Personal access tokens (classic) function like ordinary OAuth access tokens. They can be used instead of a password for Git over HTTPS, or can be used to authenticate to the API over Basic Authentication.
To create tokens, you go to Settings > Developer Settings which is right at the bottom.
You then push to github.