How can I store multiple RSA keys generated by several git accounts on a single computer, enabling multiple accounts to use the configuration at the same time? Today, unfortunately, this problem is again encountered.
Problem description
The company recently developed an open source product that was hosted on GitHub, but the company has been using Gitlab and has long been equipped with gitlab RSA keys. The previous practice was to regenerate a GitHub key, overwriting the previous Gitlab secret key. Each switchover process means that you need to regenerate a secret key every time. Only two accounts of the situation can reluctantly accept, one day again want to make a small brush copy, this acid cool really can't describe.
Solutions
Today we have a solution to the following:
First, use the terminal SSH command to generate the first default RSA secret key.
ssh-keygen -t rsa -C "$your_email"
Go straight to the carriage. Build Result:
By default, this RSA key is in your personal account. Under the. SSH directory, there is a Id_rsa private key file and a id_rsa.pub public key file. Then copy the string from the public key file.
Enter the GitHub account setting option SSH and GPG keys, paste the copy of the public key string inside the key input box, save to exit.
Through the terminal SSH test, the following prompt content appears, indicating that the secret key has been generated and added successfully.
At this point, the Id_rsa key we generate is the default. Then the second key is created in the same way, and the following prompt appears during the creation of the secret key:
We need to rename a file and the default Id_rsa key file area separately, generated after the discovery. There are two secret keys under the SSH directory:
Then we create a new config file under the. SSH directory with the following file contents:
Each secret key corresponds to the corresponding Git URL. Then empty the contents of the Known_hosts file. At this point, you are done.
We can verify the result by SSH command.
Generated by Haroopad
Multiple RSA keys (RPM) for multiple git accounts on a single computer