2つのGitHubアカウントを設定しましたが、sshキーを正しく動作させることができません。さまざまな設定を試しました。
Host github_username1
    HostName github.com
    IdentityFile ~/.ssh/rsa_1
    User username1
Host github_username2
    HostName github.com
    IdentityFile ~/.ssh/rsa_2
    User username2
git push:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
username1で機能します1:
Host github.com
    HostName github.com
    IdentityFile ~/.ssh/rsa_1
    User username1
Host github.com
    HostName github.com
    IdentityFile ~/.ssh/rsa_2
    User username2
git push username2のレポで:
ERROR: Permission to username2/repo.git denied to username1.
fatal: The remote end hung up unexpectedly
私はまた、同じ設定でgit push両方IdentityFileとUser設定を試しましたHost。出力は、最後の構成と同じです。
リモートはそのようなものなので、gitは自動的にホスト "github.com"を検索すると思います。Hostは任意のものにできます(/programming//a/3828682)。特定のレポが使用するssh configのホストを変更する方法はありますか?
〜/ .ssh / configだけでこれを解決できれば理想的です。
IdentitiesOnly=yesそれぞれにhost... sshが唯一選ばれたIDファイルを選択し、何か他のものを試してみてください/デフォルトでないことを確認するセクション