Git over ssh - set up read only user

Viewed 29

I am looking into using git for configuration management. I have set up a git repo with ssh access (standard git@server:/ ... )

I would like the following work flow:

Some persons are allowed to edit the configuration. They check out a local copy, edit whatever they need to edit and push it back to the central repo. - this is working as it should. To actually update configs, we use a common service user. This user should be able to pull information from the central repo, but no editing should be done as that user and most important, even if that user edits anything, the changes should not be pushed back to the central repo.

How can I make a repo read-only for the service user?

As far as I can see, what I want is what github offers by defining a deploy key, but also, after what I have found, that is a github feature and not a standard feature for git over ssh.

1 Answers

I would suggest using a modified workflow like git flow. Github has a version:

https://docs.github.com/en/get-started/quickstart/github-flow

  • Your users should be creating a feature branch
  • Push that branch to github
  • Create a pull request (PR)
  • Have someone review the PR
  • Only an approved PR can then be merged to the main branch (depending on the workflow)

Your devs should have limited or no access to directly merge code into your main or develop branches without a PR being involved. Those settings are made in Github (or Gitlab, BitBucket) and not provided by the core git software. This effectively allows them read-only access to those branches, while allowing them to still create branches as needed.

Related