Multiple RSA keys (RPM) for multiple git accounts on a single computer

Source: Internet
Author: User
Tags key string

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.