Friday, 4 November 2016

Configure multiple ssh keys on a pc.

https://gist.github.com/jexchan/2351996

1. Create your SSH

ssh-keygen -t rsa -C "your_email@gmail.com"
enter filename: id_rsa_jai

2. Add your keys to SSH Directory

ssh-add ~/.ssh/id_rsa_jai

3.Check all saved ssh keys to verify

ssh-add -l

4. Modify SSH Config
cd ~/.ssh/
touch config
vi config


Then add the configuration code:

# Jai Account.
Host github.com-jai
HostName github.com
User git
IdentifyFile ~/.ssh/id_rsa_jai

# Vipin Account.
Host github.com-vipin
HostName github.com
User git
IdentifyFile ~/.ssh/id_rsa_vipin

5. Add the Newly created ssh.pub file's data to your github.com account.


6. Finally add the .pub file of the newly crated ssh to the gitub account on the portal.

for mac: $ pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

7. You're done:

Now clone your repo like:
git clone git@github.com-jai:jpandit/att-demo-android.git


This will pickup Jai's Account's SSH Credentials BECAUSE OF THE HOST WE WROTE IN THE FILE