多个ssh键 [英] Multiple ssh keys

查看:49
本文介绍了多个ssh键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我在ssh帖子中看到了具有多个私钥的答案,但是我没有获得足够的声誉来添加任何评论,所以我不得不写一个新问题(对此感到抱歉).

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?

例如,我使用学校的gitlab存储库,因此我使用了一个特定的私钥,那么我在gitlab,github ....和其他使用相同私钥(但与学校不同的ssh连接)上拥有帐户一,当然).

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?

推荐答案

有什么办法可以让通用的默认私钥文件,然后有某些特定用途的其他私钥文件呢?

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

您在〜/.ssh/config文件中定义条目Host *

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

Host h1
   ...

Host *
   IdentityFile /my/default/ssh/key

请确保将其定义为 last (否则您将需要添加排除模式)

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

这篇关于多个ssh键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆