88.26 Git Multiple Users and SSH Keys
Consider the scenario where you might have
multiple user accounts on a git server. Perhaps the git accounts are
ktmary on https://gitlab.com.
Also, rather than both sharing your personal public key, you want each
to have their own private/public key pairs.
First clone the remote repository:
git clone firstname.lastname@example.org:kt/mykt.git
It is a public repository so anyone can clone it but not push to it.
Configure a local git username and email address to override any global values.
git config user.name "K T Mary" git config user.email "email@example.com" git config --list
Now create a new private/public key pair to access the repository as
$ ssh-keygen -f ~/.ssh/id_rsa_ktmary_gitlab -N "" -C firstname.lastname@example.org $ cat ~/.ssh/id_rsa_ktmary_gitlab.pub ssh-rsa AAAAB3NzaC1...A4tHGD0= email@example.com
Copy the public key into SSH Keys under User Settings in gitlab. Then configure the local repository clone to use this public key.
git config core.sshCommand "ssh -i ~/.ssh/id_rsa_ktmary_gitlab.pub -F /dev/null"
A push should then work.
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0