Search code examples
gitsshfingerprint

Git SSH public key fingerprint does not match with that on local machine


I’m trying to SSH into my github account. I added my public key to my github account and it showed the fingerprint as something like this

SHA256:aYqWu+zL3hIOWTEGvneI90fehVQt9kuGVN7ov8WlTk8

When I SSH to git, it rejects me with

permission denied(publickey)

then I run

SSH -v 

and see my client offered public key as

RSA SHA256:aYqWu+zL3hIOWTEGvneI90fehVQt9kuGVN7ov8WlTk8 [email protected]

mine has extra username@host.

Can anyone help me to get rid of this? Thanks in advance!


Solution

  • If you read GitHub's guide on connecting via SSH (https://docs.github.com/en/github/authenticating-to-github/error-permission-denied-publickey), it actually tells you NOT to connect using your username.

    All connections, including those for remote URLs, must be made as the "git" user. If you try to connect with your GitHub username, it will fail:

    $ ssh -T [email protected]
    > Permission denied (publickey).
    

    Instead, you should use ssh -i /path/to/privatekey -T [email protected] (you can leave you the -i /path/to/privatekey if you're using ssh-agent)

    Upon successful authentication, you should get a message like this: Hi username! You've successfully authenticated, but GitHub does not provide shell access.