Adding a new SSH key and token to your GitHub account

Posted under » Version Control updated on 4 December 2025

From GIT Starting a new repo. Let us try to use github instead of locally. Test connect.

$ ssh -T git@github.com

It will give a 'git@github.com: Permission denied (publickey).' error. It means there is no correcponding SSH key on github. Before adding a new SSH key to your GitHub account, you should have already generated a new SSH key.

First download your key file located at your ssh folder eg. ~/.ssh/id_ed25519.pub or cat and copy it.

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. The Key type is 'Authentication Key', not 'Signing key'.

Click Add SSH key. If prompted, confirm your GitHub password. Once successfully added try connecting to github with the verify troubleshoot option.

$ ssh -vT git@github.com
debug1: Server accepts key: /home/ubuntu/.ssh/id_ed25519 ED25519 SHA256:M2f/zpjv6Zow

Sometimes, the server accepts key but it hangs. It could be a network issue or your office IT admin prevents you from doing git. But if the command completed fully, now you can do the real test.

$ 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.

As of 2024, github no longer accept password in the clear. So go to Settings > Credentials > Personal access tokens (classic)

Personal access tokens (classic) or PAT (classic), function like ordinary OAuth access tokens. You can enable or disable admin:enterprise, admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, admin:ssh_signing_key, audit_log, codespace, delete:packages, delete_repo, gist, notifications, project, repo, user, workflow, write:discussion, write:network_configurations, write:packages, etc..

So when prompted for password, use your PAT in place of your password.

$ git branch -M main
$ git remote add origin https://github.com/anoneh/integration.git

Now you can either add files to Github with push or clone a repo.

web security linux ubuntu Raspberry   git   javascript python django Laravel drupal php apache mysql  MongoDB AWS data  ML AI