Original link http://yijiebuyi.com/blog/f18d38eb7cfee860c117d629fdb16faf.html
Usage environment: Use multiple SSH key switches for the same computer Linux system (or multiple users using SSH to submit code)
requirements, you can create a different public KEY, set according to the following steps.
(1) For example, there are AAA,BBB,CCC three accounts need to generate a different public KEY
$ ssh-keygen -t rsagenerating public/private rsa key pair. enter file in which to save the key (/ROOT/.SSH/ID_RSA):/root/.ssh/id_ rsa_aaaenter passphrase (empty for no passphrase): Enter same passphrase again:your identification has been saved in /root/.ssh/id_rsa_aaa. Your public key has been saved in /root/.ssh/id_rsa_aaa.pub.the key fingerprint is:9b:92:f6:1f:d2:72:bd:72:19:45:42:5f:e4:65:33:64 [email protected]The Key ' s randomart image is:+--[ rsa 2048]----+|     &NBSP, .... . e=| |            &NBSP, .... o++| | o. .| | . | | s . | |        . +&NBSP, .... | | + = + .o | | . o +. o. | | ...o. |+-----------------+
Into the shell above we create the ID_RSA_AAA private key and id_rsa_aaa.pub public key in the/root/.ssh/directory
Watch this.
Enter file in which to save the key (/root/.ssh/id_rsa):/root/.ssh/id_rsa_aaa #设置路径 If default build Id_rsa and Id_rsa.pub are not set
(2) Follow the above steps to generate the BBB and CCC corresponding public and private keys ....
(3) Check the system Ssh-key Agent, execute the following command
$ ssh-add-lcould Not open a connection to your authentication agent. If you find the above hint, the system agent does not have any key, do the following operations exec ssh-agent bash
If the system already has a Ssh-key agent, execute the following command to remove
$ ssh-add-d
(4) Add the 3 private keys under the. SSH directory ssh-agent
$ ssh-add ~/.ssh/id_rsa_aaa$ ssh-add ~/.ssh/id_rsa_bbb$ ssh-add ~/.SSH/ID_RSA_CCC
Execute the above three shells in turn to add three private keys to the Ssh-key agent
(5) Open the GitHub or open source China SSH Admin page to save the corresponding public key submission to the Code Management Server (. Pub end)
(6) Create config profile in. SSH Directory
Nano ~/.ssh/config
Enter the following configuration information
#aaa (GitHub config) host AAA HostName github.com User git identityfile ~/.ssh/id_rsa_aaa#bbb (open source China config) host BBB H Ostname git.oschina.net User git identityfile ~/.ssh/id_rsa_bbb#ccc ...
(6) Remember the alias set in the previous step of the Host, start cloning the project to open source China as an example
git clone [email protected]:username/projectname.git
To this end, multiple Ssh-key can already be used simultaneously.
"Go" The same computer about multiple SSH Key Management