Mac Next computer to manage multiple SSH keys

Source: Internet
Author: User

I. What is SSH?
Http://www.ruanyifeng.com/blog/2011/12/ssh_remote_login.html

Second, demand: a computer (Mac OS) to manage multiple SSH keys, you can switch arbitrarily, to achieve a multi-user (account) using different SSH submission code.
Here's an example of using Gerrit and GitHub accounts.

1) Generate SSH key

If you return all the way (password can not be written), this will only generate Id_rsa and id_rsa.pub two files in the ~/.ssh/directory. To differentiate, we set the path after the first carriage return:

Thus we generate the corresponding public and private keys for Gerrit and GitHub, respectively, after the completion of the directory:

Id_rsa_gerritid_rsa_gerrit. Pubid_rsa_githubid_rsa_github. Pub

2) Set the proxy for SSH key

1, first look at the agent

If prompted

 not open a connection to your authentication agent.

The system agent does not have any key, do the following actions

If the system already has a ssh-key agent, you can delete

Ssh-add-d

2. Add private key

Ssh-add ~/.ssh/id_rsa_gerrit ssh-add ~/.ssh/id_rsa_github

3. Add Public key

On the corresponding Gerrit and GitHub SSH Admin page, add the corresponding public key (. pub file contents) to the Code Management Server.

4. Add and edit configuration file config

Create a new config file under the ~/.ssh directory

Add content

# Gerrit Host Gerrit. xxxx. com HostName Gerrit. xxxx. com preferredauthentications publickey identityfile ~/.ssh/# GitHub Host GitHub. com HostName GitHub. com preferredauthentications publickey identityfile ~/.ssh/

Of course, you can also use the Nano command to create and edit

Thus, SSH will read the corresponding private key file according to the different domain of the login.

5. Testing

If it appears

 not Shell

Indicates success.
If it appears

Check that the public key added to GitHub's SSH management is correct.

6. Other

Submit code to Gerrit failed, error is

Remote:ERROR:In Commit xxxxxxxxxxxxxxxxxxxxxxxx remote:ERROR:committer email address [email protected].   not match your the user account. Remote:ERROR:remote:ERROR:The following addresses is currently Registered:remote:ERROR: [email protected] . com remote:ERROR:remote:ERROR:To Registeran e-mail address, please visit:remote:ERROR:http:

This error is not your previous setup to manage multiple SSH problems, but because your current git user information and the server you submitted the code to register the user information is inconsistent, that is, the server checked your user information, refused.

Here's how to fix it:

1. Edit. Gitconfig

Open ~/. = = [email protected]== [email protected] bbb.com  

2. Change Submissions

Of course, you can resubmit that, too.

git reset head^ git add-a git commit-m "xxxx"

Transferred from: http://blog.csdn.net/wwmusic/article/details/51027458

Mac Next computer to manage multiple ssh keys (RPM)

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.