Linux manages multiple SSH public key __linux

Source: Internet
Author: User
Tags chmod git client git commands

Many of the online SSH-free password use git commands do not take into account the situation of multiple public key keys, here to collect and tidy up the management of multiple SSH public key keys.

The public key and the key are generated first, and by default the public key has a file name that is more than the end of the key. Pub, for example, to manage SSH public key keys for coding.net and github.com two git warehouses (if you are under Windows, install a git client and then use Git Bash to type the following command; if it is under Linux, use the terminal directly:
Ssh-keygen-t rsa-f ~/.ssh/id_rsa.coding-c "Key for Coding.net"
Ssh-keygen-t rsa-f ~/.ssh/id_rsa.github-c "Key for GitHub Stuff"

This command specifies the file name of the key and the public key directly through the-f argument, such as-F ~/.ssh/id_rsa.coding, whose production key is ~/.ssh/id_rsa.coding and the public key is ~/.ssh/id_ Rsa.coding.pub, when the public key and the key are generated, the contents of the public key file are appended to the end of the ~/.ssh/authorized_keys file, and the same GitHub public key is generated in the same way. Note A newline character is required at the end of the Authorized_keys file before appending.

Ssh-rsa aaaab3nzac1yc2eaaaaaaaaupeye1nmmrb121244dwhwflspfifrfb1quwqtx2m/ysi8eln3vga/5ahfkkpwg+ noczwzxi0xguiyaslriiowxaujbyei5nhhbcay+gizws4u8h3zu7ugvwmqlqhf8tq/ I0j1rnr6nq8ra9882398akk23h9hhp63eagsbpkefg7qscroq0+vz2yflyjuclgxhb+eah+r9eqq4l%hef; asd8hlqw449w1szkz3hcwxfajfkbj/n+j50vnxb3flnetniq@ooikn324n802do5jizgfznrysirfbjvbhvisodyxdmz6qbqlx87xmeq== Admaaa@163.com
Ssh-rsa aaaab3nzac1yc2eaaaaa2#@8923n (& @hfg2-hg9002nkglsdfpcbuhdn185+jyojqrwlimrr6iowh/lsbs1n22po# ng3434ng90u32n@0) @ #NKDLHWO: @_jqtuibr8uzwzlim5zcn9u/djsjuaip/ sfg1jeoxfwsftowqpynbgs9vfwu83mh1iggdueaehy5mamwy57ym/+jm/hps1i3e+otdt9+k1ryigr44ur7awpkz/pmgiupuc6qfgfvp4xvrw= = myyyy@gmail.com

Also add the public key to the GIT warehouse SSH Key management where GitHub is in the SETTINGS–>SSH keys.

When more than one SSH key needs to be managed, be sure to modify the permissions of the config file, otherwise you will still be invalid if you configure
Touch ~/.ssh/config
chmod ~/.ssh/config

The contents of the ~/.ssh/config file are:
Host github.com
Identityfile ~/.ssh/id_rsa.github
User git
Host git.coding.net
Identityfile ~/.ssh/id_rsa.coding
User git

The value after user is the part of the @ before the @ of the git SSH address you visited, for example: Git@github.com:dongritengfei/beego.git's @ is ahead of git, so the value after user is git. Host is the domain name or IP of your git repository.

And then use this command to test whether or not to configure OK
Ssh-t git@github.com
Welcome to GitHub, your name!

If you see this it means you're OK, if you see the following look:
Bad owner or Permissions On/home/admin/.ssh/config

Then you need to perform:
chmod ~/.ssh/config

And then try it again should be OK.

Http://rongmayisheng.com/post/linux%E7%AE%A1%E7%90%86%E5%A4%9A%E4%B8%AAssh%E5%85%AC%E9%92%A5%E5%AF%86%E9%92%A5

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.