Multiple ssh keys

2019-05-24 23:48发布

Well, I have seen answers in the ssh post of having multiple private key, but I haven't gain enough reputations to add any comment so I have to write a new question (sorry about that).

In the post, the answer given is the config file to direct(point to) each host/username to the private key file that it suppose to use but is there any way to have a default private key file for general use, then some others private key file for some specific use?

For example, I use my school gitlab repository so I use one specific private key for it, then I have accounts on gitlab, github .... and others ssh connections that use the same private key (but different from the school one, of course).

So, is there a way to config a default private key so should it failed to use the specific key it will use the default or I have to configure everything manually?

标签: git ssh
1条回答
劳资没心,怎么记你
2楼-- · 2019-05-25 00:26

is there any way to have a default private key file for general use, then some others private key file for some specific use?

You define in your ~/.ssh/config file an entry Host *

Host h1
   ...

Host *
   IdentityFile /my/default/ssh/key

Make sure to define it last (or you would need to add exclusion patterns).

查看更多
登录 后发表回答