freeCodeCampのYouTube Git and GitHub for Beginners - Crash Courseの25:45頃にgit push origin master(私の場合はmain)をしたいのですが、下記の通りPermission denied (publickey) と出てしまいました。
PS C:\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.
そこでこちらのサイトを参考に直そうとしていました。
https://ormcat.net/blog/20210509_github-denied-publickey/
GitHub との疎通テストを行う → NG パターン
SSH コマンドのデバッグログで鍵を確認する → $ ssh -vT [email protected]
までやった結果が下の結果です。
PS C:\Users\FMV\git> ssh -T [email protected]
[email protected]: Permission denied (publickey).
PS C:\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 type 3
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_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in 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/Bq5409GjY62Pqq8
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/Bq5409GjY62Pqq8
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).
その後、
秘密鍵がそこにあるか ? と 秘密鍵と公開鍵の組み合わせは正しいか ?
をやった結果がこちらです。
PS C:\Users\FMV\git> ls ~/.ssh
Directory: C:\Users\FMV\.ssh
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 2022/09/24 18:45 demo-repo
-a--- 2022/09/24 14:15 12288 .config.swp
-a--- 2022/09/24 18:42 419 id_ed25519
-a--- 2022/09/24 18:42 109 id_ed25519.pub
-a--- 2022/09/24 18:29 2610 id_rsa
-a--- 2022/09/24 18:29 574 id_rsa.pub
-a--- 2022/09/24 13:18 832 known_hosts
-a--- 2022/09/24 10:08 92 known_hosts.old
PS C:\Users\FMV\git> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\FMV/.ssh/id_rsa):
既にYouTubeでtestkeyというkeyを作ったのでここから進めて良いのか、またどう対処すれば良いのかわからず止まっています。