質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

Q&A

1回答

2812閲覧

GitHubのSSH接続エラー

kaji120

総合スコア39

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

GitHub

GitHubは、Gitバージョン管理システムを利用したソフトウェア開発向けの共有ウェブサービスです。GitHub商用プランおよびオープンソースプロジェクト向けの無料アカウントを提供しています。

0グッド

0クリップ

投稿2021/03/28 00:28

前提・実現したいこと

GitHubにSSHで ssh -T git@github.comコマンドを使用して接続しようとしたとことエラーがでて接続できませんでした。おそらくですが、GitHubに接続する際に使用しているキーが違うと思います。もしそうであった場合は使用キーの変更方法を教えて頂きたいです。よろしくお願いいたします

発生している問題・エラーメッセージ

キーを作成してGitHubに接続しようとすると以下のメッセージが表示されます

git@github.com: Permission denied (publickey).

該当のソースコード

ファイル構成
イメージ説明

config

1Host github 2 HostName github.com 3 IdentityFile ~/.ssh/id_rsa_github 4 User git

デバッグ情報 ssh -vT git@github.comでデバッグ

UYserName@Mac-Pro .ssh % ssh -vT git@github.com OpenSSH_8.1p1, LibreSSL 2.7.3 debug1: Reading configuration data /Users/UserName/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 47: Applying options for * debug1: Connecting to github.com port 22. debug1: Connection established. debug1: identity file /Users/UserName/.ssh/id_rsa type -1 debug1: identity file /Users/UserName/.ssh/id_rsa-cert type -1 debug1: identity file /Users/UserName/.ssh/id_dsa type -1 debug1: identity file /Users/UserName/.ssh/id_dsa-cert type -1 debug1: identity file /Users/UserName/.ssh/id_ecdsa type -1 debug1: identity file /Users/UserName/.ssh/id_ecdsa-cert type -1 debug1: identity file /Users/UserName/.ssh/id_ed25519 type 3 debug1: identity file /Users/UserName/.ssh/id_ed25519-cert type -1 debug1: identity file /Users/UserName/.ssh/id_xmss type -1 debug1: identity file /Users/UserName/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.1 debug1: Remote protocol version 2.0, remote software version babeld-8b756cb2 debug1: no match: babeld-8b756cb2 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: - 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: ssh-rsa - debug1: Host 'github.com' is known and matches the RSA host key. debug1: Found key in /Users/UserName/.ssh/known_hosts:4 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: Will attempt key: /Users/UserName/.ssh/id_rsa debug1: Will attempt key: /Users/UserName/.ssh/id_dsa debug1: Will attempt key: /Users/UserName/.ssh/id_ecdsa debug1: Will attempt key: /Users/UserName/.ssh/id_ed25519 ED25519 SHA256:- debug1: Will attempt key: /Users/UserName/.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,ssh-dss-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,ssh-dss> debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /Users/UserName/.ssh/id_rsa debug1: Trying private key: /Users/UserName/.ssh/id_dsa debug1: Trying private key: /Users/UserName/.ssh/id_ecdsa debug1: Offering public key: /Users/UserName/.ssh/id_ed25519 ED25519 SHA256:- debug1: Authentications that can continue: publickey debug1: Trying private key: /Users/UserName/.ssh/id_xmss debug1: No more authentication methods to try. git@github.com: Permission denied (publickey).

試したこと

・GitHuibでキーの貼り直し、確認
・configファイルの作成、記述
・known_hostsのfingerprint情報の削除

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

git@github.com: Permission denied (publickey).

お察しのとおり、接続鍵が違う場合にこのエラーが出ます。

GitHubでssh接続する手順公開鍵・秘密鍵の生成から - Qiita

どーこーいじくるよりも、
あっさり最初からやり直してしまうほうが早そうです

投稿2021/03/28 01:21

編集2021/03/28 01:23
y_waiwai

総合スコア87719

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問