Demand:
The company has GitHub account, own GitHub account, want to use on git simultaneously, the two do not interfere.
Ideas:
Management of two Shh key.
Solution:
First, generate two SSH keys
For example, the "one"and "two"two accounts are used here. Same below
Ssh-keygen " [email protected] " ssh-keygen"[email protected]"
Don't go all the way back in the first conversation by typing the rename (id_rsa_one and id_rsa_two), which generates two copies of 4 files containing the private key and the public key.
Note 1:ssh-keygen is a Linux command that lets you use SSH between two machines without requiring a username and password
Stay 2: Be sure to run the command line under the ~/.SSH path, otherwise the resulting file will not appear in the current directory
Second, add the private key
1. Open ssh-agent
(1) If you are the official GitHub bash:
ssh-agent -S
(2) If you are other, such as Msysgit:
$ eval $ (ssh-agent -s)
2. Add private key
ssh-add ~/. ssh/ssh-add ~/. ssh/id_rsa_two
Third, create config file
Touch Config
The empty config file appears, and then add the following:
# One ([email protected]) one.github.com ~/. ssh/id_rsa_one User One # ([email protected] gmail.com) two.github.com~/. SSH/id_rsa_two User
Iv. Deployment of SSH key
Login to two GitHub accounts and enter Personal settings –> SSH and GPG keys:
Click "New SSH Key" to add the contents of the following two public keys to the respective GitHub account.
V. Remote testing "can skip"
SSH ssh –T two.github.com
Vi. Use of
1. Clone to Local
(1) The original wording:
$ git clone [email protected]: One's user name/learngit.git
(2) The current wording:
$ git clone [email protected]one.github.com: one username/learngit.git$ git clone [email protected] two.github.com: User name of two /learngit.git
2, remember to this warehouse set local user name and mailbox:
" One_name " " One_email " "two_name" "two_email "
3, the above are successful, you will find that the key will be changed from gray to green.
Git uses two github accounts on a single computer