Git clone, push and pull from multiple users on Ubuntu server

1

Background

I have a Linode server with Ubuntu 16.04 as on OS on it. The server is for my internal team. We have repos hosted on github, bitbucket and gitlab. Only server admin has the access to the server.

We have generated ssh keys for all the users, added them to git providers and cloned the repos

Problem Statement

Whenever I do git pull on server, it always asks for the main passphrase of main key file

Enter passphrase for key '/root/.ssh/id_rsa': 

When I enter the passphrase, it shows me Permission denied error

enter image description here

baig772

Posted 2017-11-29T19:26:26.727

Reputation: 113

Answers

0

You should generate a password-less key pair (just hit [enter] when ssh-keygen asks for a password). And if the server only does pulls, you man want to restrict it its rights to "read-only" on the repository side, so that if the key gets compromised it won't allow someone to damage your repository or worse add backdoors in your code.

If the problem is that you have several keys (one for each of github, bitbucket and gitlab), and git only uses one, then what you need to do is set up ~/.ssh/config to specify a different key for each server:

Host github.com
IdentityFile ~/.ssh/id_rsa_github
User someuser

but even in that case you need passwordless keys.

xenoid

Posted 2017-11-29T19:26:26.727

Reputation: 7 552

Okay. Will try that. But what if I want the password protected keys for my server? How do I tell git to ask for the passphrase for this specific key? – baig772 – 2017-11-29T20:54:11.377

Maybe misunderstood your question (who/what are the "users"?). See edited answer. – xenoid – 2017-11-29T21:23:40.300