Short tutorial on how to structure projects and setup multi-user Git SSH workflow.
When using a single machine with multiple git accounts, you might encounter some obstacles with SSH setup. The easiest way to achieve a multi-user setup is to structure git repositories by respective directories, e.g.:
projects ├── work │ ├── enterprise-fiz-buz │ └── ... └── personal ├── karolis.sh └── ...
This short tutorial will help you set up SHH for such workflow.
To generate a new SSH key, use the provided template script (or check the docs):
export EMAILfirstname.lastname@example.org export SSH_FILE=$HOME/.ssh/id_rsa_work ssh-keygen -t rsa -b 4096 -C $EMAIL -f $SSH_FILE ssh-add -K $SSH_FILE echo "🔽 PUBLIC KEY BELOW 🔽" && cat $SSH_FILE.pub pbcopy < $SSH_FILE.pub
[user] name = Karolis Šarapnickis email = email@example.com [core] sshCommand = ssh -i ~/.ssh/id_rsa [push] default = current [includeIf "gitdir:~/projects/work/"] path = ~/.gitconfig.work
[user] email = firstname.lastname@example.org [core] sshCommand = ssh -i ~/.ssh/id_rsa_work
And that's it! Appropriate SSH setup will be used based on directory location, no extra actions are needed.