I have two github account, One just for fun - my personal account and another one for work.
To switch between two account, involves quite few number of steps.
1)Generate ssh key
2)Config the ssh key in your github account
3)Set up the ssh configuration in your local system
4)Clone the code with alias name
Generate ssh key:
Generate the ssh key for both account one by one through ssh-keygen tool
To switch between two account, involves quite few number of steps.
1)Generate ssh key
2)Config the ssh key in your github account
3)Set up the ssh configuration in your local system
4)Clone the code with alias name
Generate ssh key:
Generate the ssh key for both account one by one through ssh-keygen tool
Enter the following command in git bash to create ssh-key , One for personal email and another for official email
ssh-keygen -t ed25519 -C "mypersonalemail@com"
ssh-keygen -t ed25519 -C "myofficialmail@com"
Then enter the file location where you wants to generate keys. It should be inside the .ssh folder under your name ( Be caution don't override the existing file)
Next it will ask to enter the passphrase. Enter blank. And then again it will ask for confirmation. Enter blank
Two file will get generated one contains private key and another contains public key. Copy the public key , which we will use later
Config the ssh key in your github account
To update the ssh in github, navigate to the following path (setting > SSH and GPG keys) and update the key as shown below
Set up the ssh configuration in your local system
Third step would be configuration of ssh in your local machine so that ssh client uses correct key to authenticate with respective your github account.
Create a file named as "config" under the .ssh folder. and paste new configuration
Host <#ALIAS NAME FOR PERSONAL WHICH WE USE LATER TO CLONE#> github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/<#FILE NAME OF PERSONAL KEY FILE#>
Host <#ALIAS NAME FOR OFFICIAL WHICH WE USE TO CLONE#> github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/<#FILE NAME OF OFFICIAL KEY FILE#>
Clone the code with alias name
Go to your repository in github and copy the SSH url path to clone the repository, it would look like similar to below
git@github.com:shedev/HandOn.git
Replace the github.com with alias name, then url would look like
git@<#ALIAS NAME#>:shedev/HandOn.git
To clone the code, use the following command in git bash
git clone git@<#ALIAS NAME#>:shedev/HandOn.git