Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add access to only one git repository via SSH key, not the entire host

Tags:

git

on a server, I want to have several git repositories. I want different users (=different SSH keys) to have access to different repositories (think of GitHub).

I know I can add a user's SSH key to authorized_keys on the server. But that would give the user access to all repos.

How can I set this up correctly? How does GitHub do it?

like image 865
DeX3 Avatar asked Oct 31 '22 23:10

DeX3


1 Answers

The easiest solution is to install a tool for managing remote access to git repositories, such as:

  • Gitlab
  • Gitolite
  • Gogs

If you're not willing to use any of those options, you can hack something together by binding keys in your authorized_keys file to a specific command (using the command= option) that is a wrapper that validates repository access. This answer has some ideas that might help you get started.

like image 60
larsks Avatar answered Nov 11 '22 07:11

larsks