Reputation: 32978
I am developing some private projects on Github, and I would like to add nightly cronjobs to my deployments servers to pull the latest version from github. I am currently doing this by generating keypairs on every deployment server and adding the public key to the github project as 'Deployment key'.
However, I recently found out that these deployment keys actually do have write access to the project. Hence, every of the server administrators could potentially start editing. Furthermore I can add every deployment key to only one repository, whereas I would like to be able to deploy multiple repositories on one and the same deployment server.
Is there a way to provide read-only access for private repositories to selected users on Github?
Upvotes: 170
Views: 113346
Reputation: 80282
Answer for GitHub on 2023-12-26:
git clone https://myusername:[email protected]/myusername/myproject.git
Where:
myusername
is your GitHub usernamemyproject
is the Git project name.github_pat_11AAJ3xxxxx
is the access token.To generate the access token:
[ Settings > Developer Settings > Personal Access Tokens > Fine Grained Tokens ]
.Generate New Token
, select Only select repositories
and choose the private repositories you want to grant read-only access to.Read access
to "actions, administration, code, codespaces, and metadata"
.Upvotes: 5
Reputation: 3095
I know that the questions is about github but maybe for some readers it would be nice to know that this is possible in gitlab and for free. Check https://gitlab.com/help/user/permissions. I spend some time using github without fully serving my purposes. If I knew then I would have started this particular project with gitlab.
Upvotes: 5
Reputation: 23438
I have it on good authority that the (relatively new) "Organizations" feature allows you to add people with read-only access to a private repository.
Upvotes: 78
Reputation: 2886
For Organizations: I suggest creating a new team specifically for the user. This team can then grant read-only access to the repositories you specify. I hope this helps!
Upvotes: 3
Reputation: 4473
For anyone else finding this question, know that nowadays you can in fact create read-only deploy keys:
https://github.com/blog/2024-read-only-deploy-keys
You can still create deploy keys with write access, but have to explicitly grant that permission when adding the key.
Upvotes: 54