preface

In some cases, we need to configure multiple GIthub SSH links on the same machine.

steps

Generate multiple SSHS

ssh-keygen -t rsa -C "emailxxxx"
Copy the code

It is important to note that the generated key name cannot be the same,

Then configure the corresponding public key to your Github account.

Github Configuration path: Avatar (dropdown)-> Settings ->SSH and GPG keys

Edit the SSH configuration file

Edit/create an SSH configuration file (~/.ssh/config) in the system’s current user home directory.

Host github.com-crper
    HostName github.com
    user crper
    IdentityFile "~/.ssh/id_rsa"
    IdentitiesOnly yes


Host github.com-ones
    HostName github.com
    user linqunhe
    IdentityFile "~/.ssh/id_rsa_ones"
    IdentitiesOnly yes
Copy the code

Add the agent

Ssh-add - adds private key identities to the authentication agentMultiple private keys can be added to the authentication proxy for unified maintenance
Copy the code

validation

Verifying the remote server

Pull the code

The only region is the pull code. Note that the remote domain is the configured domain!! Such as

conclusion

Configuration is not troublesome, clone maintenance of these is also good;

Of course, if only two accounts, and very lazy.

Can consider a Github Desktop to manage, very silly!