user1327064
user1327064

Reputation: 4337

How to setup multiple identities of git ssh on windows?

On my windows 7, i have created a config file that is residing in .ssh folder:-

Host office 
Hostname git@officeserver
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa 

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

but, I still unable to clone repo.

  1. Wondering How would i setup multiple hosts on windows 7?
  2. What should be the extension of config file?

Upvotes: 2

Views: 493

Answers (1)

dseminara
dseminara

Reputation: 11935

Your hostname setup is wrong, it shouldn't have the username, only the hostname

Here an example, I am using .ssh/config to keep multiple identities (each one with different key pair) on 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

This is how your config file should look:


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

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

Note you cant include usernames or port on Hostname, you should specify those on different config variables (User and Port)

Upvotes: 1

Related Questions