CentOS7 on Github/gitlab multiple account management ssh Key

Source: Internet
Author: User

Because the company team uses GITLAB to host the code, while the individual on Github also has some code warehouse, the company mailbox and personal mailbox is different, the resulting SSH key is also different, which caused the conflict, the article provides solutions to such problems: how to use the same on a machine Github and Gitlab services?

1. Generate SSH Key for Github/gitlab
$ ssh-keygen-t rsa-f ~/.ssh/id_rsa_github-c "[email protected]" $ ssh-keygen-t rsa-f ~/.ssh/id_rsa_gitlab-c "[Email p Rotected] "

Check if key is generated

$ ls ~/.ssh
2. Add private key
$ ssh-add ~/.ssh/id_rsa_github$ Ssh-add ~/.ssh/id_rsa_gitlab

If you are prompted "Could not open a connection to your authentication agent" When you execute Ssh-add, you can execute the command first:

$ ssh-agent Bash

Then run the Ssh-add command again.

# The list of private keys can be ssh-add-l by a $ ssh-add-l# can be ssh-add-d to clear the list of private keys $ ssh-add-d
3. Modify the configuration file

$ VI ~/.ssh/config

# githubhost github.com    HostName github.com    preferredauthentications publickey    identityfile ~/.ssh/id_ rsa_github# gitlabhost gitlab.example.com    HostName gitlab.example.com    preferredauthentications publickey    Identityfile ~/.ssh/id_rsa_gitlab
4. Upload public key to Github/gitlab

In GitHub, for example, the process is as follows:

Login to GitHub, click on the icon at the top right and click "Settings"

Select SSH and GPG keys, click on "New ssh key", fill in the name of SSH key in the interface that appears, fill in a name you like, and then paste the contents of the ~/.ssh/id_isa_github.pub file to key column, click on the "Add SSH Key" button to do it.

Add a process github will prompt you to enter your GitHub password once and add it after confirmation.

Taking Gitlab as an example, the process is as follows:

Click "Profile Settings"

Click "SSH keys" to add SSH key

5. Testing
# test github$ ssh-t [email protected]# test gitlab$ ssh-t [email protected]

CentOS7 on Github/gitlab multiple account management ssh Key

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.