管理两个ssh密钥 [英] Managing two ssh keys
问题描述
id_rsa
, id_rsa。 pub
和 known_hosts
。 现在我想在一台电脑上同时使用两个ssh密钥。
我该怎么做?
我如何在一台PC上管理两个ssh密钥?
创建SSH配置文件
如果您有多个身份文件,请创建一个SSH配置文件机制以为您的各种身份创建别名。
您可以使用许多参数和不同方法构建SSH配置文件。
本例中使用的别名条目的格式为:
主机别名
HostName bitbucket.org
IdentityFile〜/ .ssh / identity
要为两个身份(workid和personalid)创建配置文件,您需要执行以下操作:
打开一个终端窗口。
编辑〜/ .ssh / config文件。
如果您没有配置文件,请创建一个。例如:
主机工作单元
HostName bitbucket.org
IdentityFile〜/ .ssh / workid
主机personalid
HostName bitbucket.org
IdentityFile〜/ .ssh / personalid
PS
不要忘记将密钥加载到您的github帐户。
如何添加ssh密钥到github账户?
- 登录到github账户
- 点击右上角的牧场主(设置)
- 点击
SSH密钥
- 点击
添加ssh键
- 将您的密钥和sa ve
你们所有人都去了: - )
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
.
Now I want to use both ssh keys in one pc.
How can I do that?
How can I manage both ssh keys in one pc? I am on linux mint.
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)
- Click on the
SSH keys
- Click on the
Add ssh key
- Paste your key and save
And you all set to go :-)
这篇关于管理两个ssh密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!