Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

We have a web server which contains a web application stored as a github project. Now all of us can push from our local machines to github and then pull from the web server.

Sometimes we want to make small changes on the web server and immediately see the effect so it would be great to be able to push from the web server too.

Now I created an ssh key for the server but I don't want to add the servers ssh key to my github account because then all github actions done from the server are counted to my account. I also don't want to copy my private key to the server obviously.

Is it possible to add the ssh key of the web server to the github web application project without creating a new user for the server and what is the best practice for this situation?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

SSH keys are per-account on github (and everywhere else) and you neither want an account for the server nor attach the server to one of the personal accounts.

I take it you have only one account for everybody on the web server to edit the git repo / web application. Otherwise you wouldn't have the restriction of a single key for the server.

So if you really want to push from the server directly to github, you have to create different logins/user on the web server and then login as one of these users to push to github.

You have to make sure that all of these users have write access to the .git folder and every file created by git will retain this access.

My idea would be to force a group git for the whole repository with

chgrp -R git <git repo dir>
chmod -R g+s <git repo dir>

and then force write access per default for new files for that group with

setfacl -R -m d:g:git:rwX

This would be my solution for a linux web server with ACLs. In case you have a windows web server you can do the same, but you obviously have to do that in the GUI or use other commands.


In terms of github/ssh configuration you would create an ssh key for every user on the web server and every user adds them to their personal git user account. You still should not copy the private key from your machine to the web server.

share|improve this answer
    
Thank you very much! –  Konrad Höffner Dec 20 '12 at 18:40

Please never have several users with the same account. It just leads to washing out of responsibilities.

share|improve this answer
1  
most rules have exceptions which make "never" and "always" overly strong words. –  Sirex Jan 15 '13 at 19:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.