Managing two ssh keys

前端 未结 1 1343
面向向阳花
面向向阳花 2021-01-28 09:31

Suppose, I have two pc and in each pc I have a .ssh folder and in each folder I have three files id_rsa, id_rsa.pub and known_hosts.

相关标签:
1条回答
  • 2021-01-28 09:56

    Create a SSH config file

    When you have multiple identity files, create a SSH config file mechanisms to create aliases for your various identities.

    You can construct a SSH config file using many parameters and different approaches.

    The format for the alias entries use in this example is:

    Host alias 
      HostName bitbucket.org 
      IdentityFile ~/.ssh/identity
    

    To create a config file for two identities (workid and personalid), you would do the following:

    Open a terminal window.
    Edit the ~/.ssh/config file. 
    

    If you don't have a config file, create one.
    Add an alias for each identity combination for example:

    Host workid
    HostName bitbucket.org
    IdentityFile ~/.ssh/workid
    
    Host personalid
    HostName bitbucket.org
    IdentityFile ~/.ssh/personalid
    

    PS

    Don't forget to load the keys to your github account.

    How to add ssh key to github account?

    • Login to github account
    • Click on the rancher on the top right (Settings)
      github account settigns
    • Click on the SSH keys
      ssh key section
    • Click on the Add ssh key
      Add ssh key
    • Paste your key and save

    And you all set to go :-)

    0 讨论(0)
提交回复
热议问题