Add an SSH public key to multiple accounts on GitHub

Source: Internet
Author: User

You can add multiple SSH keys in the background of GitHub, but the same SSH keys can only be added to an account ("Key is already" when added). The reason is easy to think that SSH public key use is equivalent to the user name password, it is not possible to two different accounts with the same user name password. To add a public key to multiple github accounts, generate multiple SSH keys locally, one for each GitHub account, and a different SSH keys. The steps are as follows:
1. Generate a new SSH KEY

  1. [Email protected] : ~$ ssh-keygen -t RSA -C ' [email protected] '
  2. Generating public/private RSA key pair.
  3. Enter file in which to save the key (~/. SSH/id_rsa): ~/. SSH/id_rsa2 #这里输入一个新的ssh key file name
  4. Enter Passphrase (empty for no passphrase):
  5. Enter same Passphrase again:
  6. Your identification have been saved in ~/. SSH/id_rsa2.
  7. Your public Key had been saved in ~/. SSH/id_rsa2. Pub.
  8. The key fingerprint is:
  9. 3a:01: 17:b3:f9 :26:5b: 53:b3:69 :be:71: a8:66:f6 :96 [Email protected]. Me
  10. The key' s Randomart image is:
  11. +--[RSA 2048]----+
  12. | o |
  13. | = |
  14. | . + O |
  15. | . . . + |
  16. | o S + |
  17. | B +. |
  18. | + .+ + |
  19. | . E.. + |
  20. | +.oo |
  21. +-----------------+
  22. [Email protected]:~$ ssh-add ~/.ssh/id_rsa2
  23. Identity added: ~/.SSH/ID_RSA2 (~/.SSH/ID_RSA2)

~/.SSH/ID_RSA2 for the new SSH keys file name, according to the actual situation, to ensure that each time is different.
2. Open the newly generated ~/.ssh/id_rsa2.pub file and add the contents to the GitHub backend.
3. Open the ~/.ssh/config file (not created) and add a host:

    1. #建一个github别名, the new account is cloned and updated with this alias
    2. Host github2
    3. HostName GitHub. COM
    4. User git
    5. Identityfile ~/.ssh/id_rsa2. Pub

4. Replace the [email protected] in the GitHub SSH warehouse address with the new host alias.
If the original address is: [email protected]:freehost/mail.git, after the replacement should be: Github2:freehost/mail.git
If you are creating a new warehouse, use the replacement URL clone directly. If you have cloned using the original address, you can use the command to modify:

    1. Git remote set-URL Origin github2:freehost/mail. git

original articles, reproduced please specify: reproduced from www.webmaster.me

This article link address: Add SSH Public key to multiple accounts on GitHub

Add an SSH public key to multiple accounts on GitHub

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.