두 개의 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에서 작동합니다.
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는 원하는 모든 것이 될 수 있다고합니다 ( https : //.com/a/3828682 ). ssh 설정에서 특정 repo가 사용해야하는 호스트를 변경하는 방법이 있습니까?
~ / .ssh / config 에서이 문제를 해결할 수 있다면 이상적입니다.
IdentitiesOnly=yes각host섹션 을 추가해야 할 수도 있습니다 .