Skip to content

Instantly share code, notes, and snippets.

@k4zek4ge
Last active July 25, 2022 08:40
Show Gist options
  • Select an option

  • Save k4zek4ge/3b54d0cfe06068f7736e3ae43a87df12 to your computer and use it in GitHub Desktop.

Select an option

Save k4zek4ge/3b54d0cfe06068f7736e3ae43a87df12 to your computer and use it in GitHub Desktop.
[multiple git accounts] #git
ls -al ~/.ssh
#
# generate ssh key
#
ssh-keygen -t rsa -C "email@work_mail.com" -f "id_rsa_work_user1"
#
#Adding the new SSH key to the corresponding GitHub account
#
Copy the public key pbcopy < ~/.ssh/id_rsa.pub and then log in to your personal GitHub account:
1 Go to Settings
2 Select SSH and GPG keys from the menu to the left.
3 Click on New SSH key, provide a suitable title, and paste the key in the box below
4 Click Add key — and you’re done!
#
#Registering the new SSH Keys with the ssh-agent
#
ssh-add ~/.ssh/id_rsa_work_user1
#
#Creating the SSH config File
#
cd ~/.ssh/
touch config // Creates the file if not exists
code config // Opens the file in VS code, use any editor
# Personal account, - the default config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
# Work account-1
Host github.com-work_user1
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_work_user1
#
#Clone repo
#
git clone [email protected]_user1:work_user1/repo_name.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment