git Permission denied (publickey)

Asked 1 years ago, Updated 1 years ago, 343 views

I would like to do a git push origin master (main in my case) around 25:45 of freeCodeCamp's YouTube Git and GitHub for Beginners-Crash Course, but it says Permission denied (publickey) as below.

PSC:\Users\FMV\git>git push origin main
[email protected]: Permission denied (publickey).
fatal —Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

So I was trying to fix it by referring to this site.
https://ormcat.net/blog/20210509_github-denied-publickey/

Conduct communication test with GitHub→NG pattern
Check SSH Command Debug Log for Keys → $ssh-vT [email protected]
Below are the results we've done so far.

PSC:\Users\FMV\git>ssh-T [email protected]
[email protected]: Permission denied (publickey).
PSC:\Users\FMV\git>ssh-vT [email protected]
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Connecting to github.com [20.27.177.113] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\FMV/.ssh/id_rsa type 0
debug1: identity file C:\\Users\\FMV/.ssh/id_rsa-cert type-1
debug1: identity file C:\\Users\\FMV/.ssh/id_dsa type-1
debug1: identity file C:\\Users\\FMV/.ssh/id_dsa-cert type-1
debug1: identity file C:\\Users\\FMV/.ssh/id_ecdsa type-1
debug1: identity file C:\\Users\\FMV/.ssh/id_ecdsa-cert type-1
debug1: identity file C:\\Users\\FMV/.ssh/id_ed25519 type3
debug1: identity file C:\\Users\\FMV/.ssh/id_ed25519-cert type-1
debug1: identity file C:\\Users\\FMV/.ssh/id_xmss type-1
debug1: identity file C:\\Users\\FMV/.ssh/id_xmss-cert type-1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug1: Remote protocol version 2.0, remote software version babeld-98e6a628
debug1: no match:babeld-98e6a628
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1:kex:host key algorithm:ecdsa-sha2-nistp256
debug1:kex:server->client cipher:[email protected] MAC:<implicit>compression: none
debug1:kex:client->server cipher:[email protected] MAC:<implicit>compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256: p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM
debug1: Host 'github.com' is known and matches the ECDSA host key.
debug1: Found key in C:\\Users\\FMV/.ssh/known_hosts:3
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYSent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: Will attempt key: C:\\Users\\FMV/.ssh/id_rsa RSA SHA256:nz+XwOvg8KN+x4tgzz7eNc77ThGLQn3UOJKECkWjwK0
debug1: Will attempt key: C:\\Users\\FMV/.ssh/id_dsa
debug1: Will attempt key: C:\\Users\\FMV/.ssh/id_ecdsa
debug1: Will attempt key: C:\\Users\\FMV/.ssh/id_ed25519 ED25519 SHA256:+fvNB2EJB6PpPULfb7cCEuS/9vR/Bq5409GjY62Pq8
debug1: Will attempt key: C:\\Users\\FMV/.ssh/id_xmss 
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected],[email protected], [email protected], [email protected], ssh-ed25519, ecdsa-sha2-nistp521, ecdsa-sha2-nistp384, ecdsa-sha2-nistp256, rsa-sha2-512, rsa-sha2-256, ssh-rsa>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\FMV/.ssh/id_rsa RSA SHA256:nz+XwOvg8KN+x4tgzz7eNc77ThGLQn3UOJKECkWjwK0
debug1: Authentications that can continue: publickey
debug1: Trying private key: C:\\Users\\FMV/.ssh/id_dsa
debug1: Trying private key: C:\\Users\\FMV/.ssh/id_ecdsa
debug1: Offering public key: C:\\Users\\FMV/.ssh/id_ed25519 ED25519 SHA256:+fvNB2EJB6PpPULfb7cCEuS/9vR/Bq5409GjY62Pq8
debug1: Authentications that can continue: publickey
debug1: Trying private key: C:\\Users\\FMV/.ssh/id_xmss
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

After that,
Is the private key there and the combination of private and public keys correct?
Here's the result.

PSC:\Users\FMV\git>ls to /.ssh

    Directory: C:\Users\FMV\.ssh

Mode LastWriteTime Length Name
----                 -------------         ------ ----
d----- September 24, 2022 18:45 demo-repo
-a--- September 24, 2022 14:15 12288.config.swp
-a--- September 24, 2022 18:42419 id_ed25519
-a--- September 24, 2022 18:42 109 id_ed25519.pub
-a--- September 24, 2022 18:29 2610 id_rsa
-a--- September 24, 2022 18:29574 id_rsa.pub
-a--- September 24, 2022 13:18832 known_hosts
-a--- September 24, 2022 10:0892 known_hosts.old

PSC:\Users\FMV\git>ssh-keygen-trsa
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\FMV/.ssh/id_rsa): 

I have already created a key called testkey on YouTube, so I don't know if I can proceed from here or how to deal with it, so it has stopped.

Thank you for your advice.
Enter a description of the image here

git

2022-09-30 22:05

2 Answers

I also answered here, but please follow the instructions on the official site without referring to the external site description.
It can only cause unnecessary confusion, and other people (candidates) can't see what the questioner actually did.

id_ed25519.pub needs to be registered with GitHub. Did this happen?
If you experience this problem after that (as stated in the description), refer to
Troubleshooting and if the problem still persists, describe the situation here.


2022-09-30 22:05

Permission denied (publickey).

This is when the connection key is incorrect or the connection key is set incorrectly.
Why don't you take a look at it?


2022-09-30 22:05

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.