Go to TogaWare.com Home Page. GNU/Linux Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Git Multiple Users and SSH Keys

20200914 Consider the scenario where you might have multiple user accounts on a git server. Perhaps the git accounts are ktfred and 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 git@gitlab.com: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 "ktmary@kt.com"
$ git config --list

Now create a new private/public key pair to access the repository as ktmary.

$ ssh-keygen -f ~/.ssh/id_rsa_ktmary_gitlab -N "" -C ktmary@kt.com
$ cat  ~/.ssh/id_rsa_ktmary_gitlab.pub
ssh-rsa AAAAB3NzaC1...A4tHGD0= ktmary@kt.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.

$ git push


Support further development by purchasing the PDF version of the book.
Other online resources include the Data Science Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 1995-2020 Togaware Pty Ltd. Creative Commons ShareAlike V4.