About git ssh-key: solve the problem of multiple local ssh-keys

Source: Internet
Author: User

When setting GitHub, the official instructions require that the current id_rsa be backed up and a new private key be generated for GitHub login. If this is done, the new private key cannot continue to log on to the previous machine. This method is a bit violent...
Fortunately, SSH allows us to log on to different domains using different private keys.


When adding a private key, you can specify different file names to generate different private key files.

 
Ssh-keygen-t rsa-f ~ /. Ssh/id_rsa.work-c "key for work" ssh-keygen-t rsa-f ~ /. Ssh/id_rsa.github-c "key for GitHub"

Add SSH configuration files and modify permissions

 
Touch ~ /. Ssh/configchmod 600 ~ /. Ssh/config

Modify the content of the config file

 
Host * .workdomain.com identityfile ~ /. Ssh/id_rsa.work user Lee host github.com identityfile ~ /. Ssh/id_rsa.github user git
In this way, SSH will read the corresponding private key file based on different domains.
 
Ssh-T [email protected]


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.