When a push fails with a permission error, I want to know whether the key works at all before I start blaming the remote URL. One command tells you.
ssh -T [email protected]
If the key is fine, GitHub answers with a greeting that includes your user name and a note that it does not offer shell access, and then closes the connection. -T tells ssh not to ask for a terminal, which avoids a pointless warning since there is no shell anyway.
The user name in that greeting is the interesting part. If you have two accounts, it tells you which one this key belongs to, and that explains a lot of “repository not found” errors on private repos.
When it fails, add -v to see which keys ssh offers:
ssh -vT [email protected]
Look for the lines with Offering public key. If your key is not in the list, the agent does not have it or your ssh config points to another file. GitLab, Codeberg and Forgejo instances answer to the same test with git@ and their own host name.
One thing to watch: the first time, ssh asks you to confirm the host key. Compare it with the fingerprints the provider publishes in its documentation before you type yes.
Further reading: Testing your SSH connection (GitHub Docs), ssh man page