

freeCodeCampのYouTube Git and GitHub for Beginners - Crash Courseの25:45頃にgit
push origin master(私の場合はmain）をしたいのですが、下記の通りPermission denied (publickey)
と出てしまいました。

[code]

     PS C:\Users\FMV\git> git push origin main
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
[/code]

そこでこちらのサイトを参考に直そうとしていました。  
<https://ormcat.net/blog/20210509_github-denied-publickey/>

GitHub との疎通テストを行う → NG パターン  
SSH コマンドのデバッグログで鍵を確認する → $ ssh -vT git@github.com  
までやった結果が下の結果です。

[code]

    PS C:\Users\FMV\git> ssh -T git@github.com
    git@github.com: Permission denied (publickey).
    PS C:\Users\FMV\git> ssh -vT git@github.com
    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: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
    debug1: kex: client->server cipher: chacha20-poly1305@openssh.com 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=<ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,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.
    git@github.com: Permission denied (publickey).
    
[/code]

その後、  
秘密鍵がそこにあるか ? と 秘密鍵と公開鍵の組み合わせは正しいか ?  
をやった結果がこちらです。

[code]

    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): 
    
[/code]

既にYouTubeでtestkeyというkeyを作ったのでここから進めて良いのか、またどう対処すれば良いのかわからず止まっています。

アドバイスよろしくお願いいたします。  
[![画像の説明をここに入力](https://i.stack.imgur.com/9Zzn1.jpg)](https://i.stack.imgur.com/9Zzn1.jpg)


CC BY-SA 4.0
2022-09-25T01:32:08.010
91284
2022-09-26T00:32:23.857
2022-09-25T05:23:01.397
53823
53823
question
git
git Permission denied (publickey)


> Permission denied (publickey).

ってのは、接続鍵が間違っている、あるいは接続鍵の設定が間違っている、場合に出ます。  
そこらへんみなおしてみては


CC BY-SA 4.0
2022-09-25T13:02:02.967
91295
2022-09-25T13:02:02.967
27481
91284
answer


[こちら](https://ja.stackoverflow.com/a/91301/2808)でも回答しましたが、外部のサイトの説明は参考にせずに、公式サイトの手順に沿って作業してください。  
余計な混乱を招くだけですし、他者(回答候補者)から見て質問者が実際に何をやったのかが把握できません。

* * *

[`id_ed25519.pub` を GitHub
へ登録する](https://docs.github.com/ja/authentication/connecting-to-github-with-
ssh/adding-a-new-ssh-key-to-your-github-account#adding-a-new-ssh-key-to-your-
account)必要がありますが、この操作は行われたでしょうか。  
その上でこの問題が出た場合、(説明文にもある通り)[トラブルシューティング](https://docs.github.com/ja/authentication/troubleshooting-
ssh/error-permission-denied-publickey)を参照し、それでも問題が解決しなかった場合、状況をこちらに記載してください。


CC BY-SA 4.0
2022-09-26T00:24:27.747
91302
2022-09-26T00:32:23.857
2022-09-26T00:32:23.857
2808
2808
91284
answer