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.:
1projects2├── work3│ ├── enterprise-fiz-buz4│ └── ...5└── personal6 ├── karolis.sh7 └── ...
This short tutorial will help you setup SHH for such workflow.
To generate a new SSH key use the provided template script (or check the docs):
1export EMAIL=[email protected]2export SSH_FILE=$HOME/.ssh/id_rsa_work3ssh-keygen -t rsa -b 4096 -C $EMAIL -f $SSH_FILE4ssh-add -K $SSH_FILE5echo "🔽 PUBLIC KEY BELOW 🔽" && cat $SSH_FILE.pub6pbcopy < $SSH_FILE.pub
1[user]2 name = Karolis Šarapnickis3 email = [email protected]4[core]5 sshCommand = ssh -i ~/.ssh/id_rsa6[push]7 default = current8[includeIf "gitdir:~/projects/work/"]9 path = ~/.gitconfig.work
1[user]2 email = [email protected]3[core]4 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.
Front-end Tech Lead @ Tesonet