0% found this document useful (0 votes)
56 views

GitGuardian GitHub Accounts Cheatsheet

This document provides an 8-step process to set up multiple Git accounts: 1. Generate an SSH key for each account. 2. Add a passphrase for extra security. 3. Add your keys to the SSH agent. 4. Create an SSH config file to select the appropriate key. 5. Copy your public key to services like GitHub. 6. Set up workspaces and Git config files for each account. 7. Configure the Git config files to specify the right key and user details for each workspace. 8. Repeat the process for additional required accounts.

Uploaded by

wagek
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views

GitGuardian GitHub Accounts Cheatsheet

This document provides an 8-step process to set up multiple Git accounts: 1. Generate an SSH key for each account. 2. Add a passphrase for extra security. 3. Add your keys to the SSH agent. 4. Create an SSH config file to select the appropriate key. 5. Copy your public key to services like GitHub. 6. Set up workspaces and Git config files for each account. 7. Configure the Git config files to specify the right key and user details for each workspace. 8. Repeat the process for additional required accounts.

Uploaded by

wagek
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

GitGuardian [8 easy steps to set up multiple git accounts — 2021]

0 1 generate a ssh key 0 6 set up your workspace

-t is the algorithm, ED25519 is recommended for Create specifics .gitconfigs for each account/ /myhome/

ssh-keygen \

security and performance


directory.
|__.gitconfig

-t ed25519 \

-C is for adding your associated email as a |__work/

-C "[email protected]" \

comment
|__.gitconfig.work

-f ~/.ssh/<personal_key>
-f is to define a filename, helping you remember |__personal/

which key is used for which user/remote.


|__.gitconfig.pers

0 2 add a passphrase
0 7 set up your git con f igs
Add an extra layer of security: if someone gains
access to your computer, your keys will be ssh-keygen -p -f ~/.ssh/<personal_key> Tell Git which key to use with the SSH command (-i option to specify an identity file/key).

compromised unless they are attached to a To update the passphrase for your SSH key at # ~/personal/.gitconfig.pers
# ~/work/.gitconfig.work

passphrase.
any time

[user]
[user]

email = [email protected]
email = [email protected]

name = Your Name


name = Your Name

[github]
[github]

03 add your key to ssh-agent user = “mynickname”

user = “pro_name”

[core]
[core]

sshCommand = “ssh -i ~/.ssh/<personal_key>” sshCommand = “ssh -i ~/.ssh/<professional_key>”


Make sure the ssh-agent is running, and add your
eval "$(ssh-agent -s)" && \

key (the -K option is to store the passphrase in


ssh-add -K ~/.ssh/<personal_key> # ~/.gitconfig

your keychain, macOS only).


[includeIf “gitdir:~/personal/”] # include for all .git projects under personnal/

path = ~/personal/.gitconfig.pers

[includeIf “gitdir:~/work/”]

path = ~/work/.gitconfig.work

0 4 create a ssh con f ig [core]

excludesfile = ~/.gitignore # valid everywhere


Host is set to * for every key because we will use
Git configs to select the appropriate SSH key # ~/.ssh/config

To see a list of all config the options


man git-config

based on profiles, which will give us a bit more


flexibility .
Host *
To check your activated config options
AddKeysToAgent yes
git config --list
UseKeychain yes

IdentityFile ~/.ssh/<created_key>

0 8 R epeat f ro m 1 f or every re q uired account

05 Copy it to your vcs You are done! You can now choose to
Copy your key to your clipboard and then
paste it in GitHub, GitLab or BitBucket
macOS tr -d '\n' < ~/.ssh/<created_key>.pub | pbcopy clone your repo git clone git@<repository.domain.com>:<username>/<repo_name>.git

Linux xclip -sel clip < ~/.ssh/<created_key>.pub add your remote git remote add origin git@<repository.domain.com>:<username>/<repo_name>.git

Windows cat ~/.ssh/<created_key>.pub | clip or change it git remote set-url origin git@<repository.domain.com>:<username>/<repo_name>.git

You might also like