小编Dav*_*ong的帖子

使用多个 SSH 公钥

我在 Unfuddle 上有一个个人帐户和一个公司帐户。在 Unfuddle 上,SSH 密钥只能用于一个帐户,因此我需要在我的笔记本电脑上为两个帐户创建一个单独的 SSH 密钥。我跑去ssh-keygen -t rsa生成两个不同名称的密钥(个人是默认名称,公司是 {company}_rsa)。现在的问题是,我的默认密钥似乎无处不在,我无法找到如何在 Git 中为单个存储库指定要使用的密钥。

所以我的问题是:如何指定要在 repo-to-repo 基础上使用的 SSH 密钥?

我设置了我的 ssh_config (~/.ssh/config) 但它似乎仍然不起作用。

配置:

Host {personalaccount}.unfuddle.com
     HostName {personalaccount}.unfuddle.com
     User git
     IdentityFile /Users/dave/.ssh/id_rsa

Host {companyaccount}.unfuddle.com
     HostName {companyaccount}.unfuddle.com
     User git
     IdentityFile /Users/dave/.ssh/cage_rsa
Run Code Online (Sandbox Code Playgroud)

我的公司 unfuddle 帐户上的仓库的 Git 仓库配置文件如下所示:

[remote "origin"]
     url = git@{companyaccount}.unfuddle.com:{companyaccount}/overall.git
     fetch = +refs/heads/*:refs/remotes/origin/*
Run Code Online (Sandbox Code Playgroud)

所以我不确定我的 ssh 配置或我的 git 配置是否有问题。

git ssh-keys

97
推荐指数
1
解决办法
7万
查看次数

标签 统计

git ×1

ssh-keys ×1