2014-09-12 65 views
1

在我的Windows 7,我已经创建了居住在的.ssh文件夹中的配置文件: -如何在Windows上设置git ssh的多重身份?

Host office 
Hostname [email protected] 
PreferredAuthentications publickey 
IdentityFile ~/.ssh/id_rsa 

Host home 
Hostname [email protected]:8888 
PreferredAuthentications publickey 
IdentityFile ~/.ssh/id_home 

,但是,我仍然无法克隆回购。

  1. 想知道如何设置Windows 7上的多个主机?
  2. 什么应该是配置文件的扩展?

回答

1

您的主机名设置是错误的,它不应该有用户名,只有主机名

这里一个例子,我使用的.ssh/config来保持多个身份(每一个不同的密钥对)在github.com:


#Default GitHub 
Host github.com 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa 
Host github-companyname.com 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa_companyname 
Host git.i411-companyname.com 
    HostName git.i411-companyname.com 
    User git 
    IdentityFile ~/.ssh/id_rsa_companyname 

这是你的配置文件应该是什么样子:


Host office 
Hostname officeserver 
User git 
IdentityFile ~/.ssh/id_rsa 

Host home 
Hostname myhome.net 
User git 
Port 8888 
IdentityFile ~/.ssh/id_home 

注意你不能包括用户名或端口主机名,你应该指定那些不同的配置变量(用户端口

+0

嗨谢谢..still同样的问题。问题:克隆时是否需要对repo地址进行更改? – user1327064 2014-09-12 15:14:30

+0

你把它克隆为git @ office:path/to/repo或者git @ home:path/to/repo – dseminara 2014-09-12 15:22:57