SSH key switching for multiple github accounts

Source: Internet
Author: User

Switch the SSH key of multiple github accounts to ssh-keygen-t rsa-C 'second @ mail.com '. By default, SSH only reads id_rsa, so in order for SSH to identify the new private key, you need to add it to SSH agentssh-add ~ /. Ssh/id_rsa_second if the command returns the following error: cocould not open a connection to your authentication agent. Unable to connect to the ssh agent, run the ssh-agent bash command and then run the ssh-add command. After completing the above steps, go ~ /. Create a config file in the ssh Directory, which is used to configure the server corresponding to the private key. The content is as follows: # Default github user (first@mail.com) Host github.com HostName github.com User git IdentityFile C:/Users/username /. ssh/id_rsa # second user (second@mail.com) Host github-second HostName github.com User git IdentityFile C:/Users/username /. ssh/id_rsa_secondHost can be used at will to facilitate your memory and will be used later when remote access is added. After the configuration is complete, when connecting to the github repository of a non-default account, make some changes to the address of the remote library. For example, add a repository test under the second Account, add: git remote add test git @ github-second: second/test. git # not the original git@github.com: second/test. git uses id_rsa_second to connect to the server each time it connects. This is a success! Note: 1: github according to the configuration file user. email to get github account display author information, so for multi-account users must remember to change user. email to the corresponding email (second@mail.com ). 2: it is better to write an absolute path to the above path, so it is not easy to make an error (at first I made an error mainly because of the path problem ..........)

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.