Posted under » Version Control on 24 April 2021
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.
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
As of 2024, github no longer accept plain clear password. It is being replaced by tokens. So when password is prompted, you put token instead.
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
You then push to github.