前提
仕事用と個人用にgithubのアカウントを切り分けたくgithubのそれぞれのアカウントに公開鍵を設定後、ssh/configファイルにサブアカウントの記述を追加しました。
仕事用ではHost github
個人用ではHost github-subと設定しssh -T [Host]と接続テストを行ったところ個人用の方でのみPermission deniedと表示されました。
実現したいこと
github-subで接続できたことを確認したいです。
該当のソースコード
config
#github Host github HostName github.com IdentityFile ~/.ssh/[仕事用秘密鍵] User git #github sub Host github-sub HostName github.com IdentityFile ~/.ssh/[個人用秘密鍵] User git-mine
試したこと
・github サブアカウント 切り替え
・github サブアカウント Permission denied
など複数アカウントを作成される際の手順は検索し一通り試しました。
また、一から公開鍵、秘密鍵を作成し再設定するなど手順の確認はしました。
個人用のgithubで作成したリポジトリに試しにpushしたところ仕事用のアカウントのままだったためにアクセス権限がなく今回アカウントを切り分けようと思いました。
上記のssh接続テストは完了していませんがgit remoteで個人用にURLを書き換え後にpushした際はgithub上で内容が更新されており鍵の設定は上手くいっているような気がしていますがなぜ反映は上手くいっているのか、ssh接続テストはなぜ通らないのか原因がわからないのでお力をお貸しいただければと思います。
補足情報(FW/ツールのバージョンなど)
VSCode
VSCode プラグイン git graph
を使用しています
gitはコマンドで行うように意識はしていますがまだまだ初心者です。
※追記 エラーメッセージ
OpenSSH_8.6p1, LibreSSL 2.8.3 debug1: Reading configuration data /Users/[個人名]/.ssh/config debug1: /Users/[個人名]/.ssh/config line 211: Applying options for github-sub debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 21: include /etc/ssh/ssh_config.d/* matched no files debug1: /etc/ssh/ssh_config line 54: Applying options for * debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling debug1: Connecting to github.com port 22. debug1: Connection established. debug1: identity file /Users/[個人名]/.ssh/id_rsa-[個人名] type 0 debug1: identity file /Users/[個人名]/.ssh/id_rsa-[個人名]-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_8.6 debug1: Remote protocol version 2.0, remote software version babeld-b9c2a189 debug1: compat_banner: no match: babeld-b9c2a189 debug1: Authenticating to github.com:22 as 'git-[個人名]' debug1: load_hostkeys: fopen /Users/[個人名]/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory 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: SSH2_MSG_KEX_ECDH_REPLY received debug1: Server host key: ecdsa-sha2-nistp256 SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM debug1: load_hostkeys: fopen /Users/[個人名]/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory debug1: Host 'github.com' is known and matches the ECDSA host key. debug1: Found key in /Users/[個人名]/.ssh/known_hosts:21 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/[個人名]/.ssh/id_rsa-[個人名] RSA SHA256:dYlusejXbPfwxdasA93kD43blgj3dd/ymhYukP/ovN4 explicit 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: /Users/[個人名]/.ssh/id_rsa-[個人名] RSA SHA256:dYlusejXbPfwxdasA93kD43blgj3dd/ymhYukP/ovN4 explicit debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. git-[個人名]@github.com: Permission denied (publickey).
回答1件