Host github-A HostName github.com User git IdentityFile /Users/xxx/.ssh/id_rsa_A IdentitiesOnly yes Host github-B HostName github.com User git IdentityFile /Users/xxx/.ssh/id_rsa_B IdentitiesOnly yes
config files are saved in different host ssh keys used.
scenes to be used:
problem
Do you have multiple accounts in github, when push code needs to use a different ssh-key, but git remote -v see the default is [email protected] : xxxRepo / xxx.git (git user name, github.com Host is the name). As a result, the use of a configuration is the same, with a private key.
Solution:
As above, two different configurations Host. Then under the repo, Git Remote SET-URL Origin Git @ GitHub-A: repoA / xxx.git can distinguish the
config configuration Meaning
-
Host
Host is used to specify the name of the key, and here you must use local repo's hostnamegithub-A
.
Host
Must be followed by the repohostname
agreement remain, that will use their own time to git repo ishostname
to find ssh configuration file which is not a correspondingHost
, found on the use of this configuration, the domain name will be used to access specificHostName
-
Hostname
Specified hereHost
corresponds to a specific domain name -
User git
Description of the configuration of the user is obtained git -
IdentityFile /Users/xxx/.ssh/id_rsa.github
This is the most critical line, which specifies the use of ssh key file, here's some key document refers to the private key file. -
IdentitiesOnly yes
Configured toyes
the specific meaning can refer to the discussion . This configuration file can be ignored.
Author: drying rack balcony
link: https: //www.jianshu.com/p/45201d18cc7c
Source: Jane books