progrium / gitreceive

Easily accept and handle arbitrary git pushes
1.14k stars 108 forks source link

upload-key permission denied #5

Closed sijk closed 11 years ago

sijk commented 11 years ago

I really like the idea of having repos created when pushed to -- nice work!

One thing that's hanging me up, though, is when I try to upload a key. The git user's authorized_keys file is writable only by git, as I understand is required by ssh. Therefore when I run

cat ~/.ssh/id_rsa.pub | sijk@server 'gitreceive upload-key sijk'

I get a permission denied error. From my understanding of ssh etc. I don't see how it could possibly work, but presumably it works for you...?

ghost commented 11 years ago

You'd have to run sudo first: cat ~/.ssh/id_rsa.pub | ssh sijk@server 'sudo gitreceive upload-key sijk'

I've created a PR to notate this in the README.

sijk commented 11 years ago

Hmm, I suspected as much. I'm trying to figure out how to let unprivileged users (non-sudoers) upload their own keys. Current musings:

I don't know if all that's possible, but I'll experiment with it when I get the time.

progrium commented 11 years ago

Giving git user a trivial password will probably kill the experience of pushing with git. I'm not sure what you mean by making it a restrictive shell or how that would help.

It's all just a permissions issue. You can create a non-root, non-git user that has access to write to the git user's authorized_keys file and give that user a trivial password. Or you can wrap some kind of automation (a web server maybe) around it that runs as a user with permission.

This is why I was hesitant about your pull request -- you don't need to be root to use gitreceive upload-key and now it implies you do.

ghost commented 11 years ago

Hmm - true. Perhaps a note before we start diving into examples is needed. Something along the lines of "in this document sudo is used to escalate privileges as needed, but you may run the commands from any user that has access to ~git/.ssh/authorized_keys." I'll let you refine & place it somewhere that makes sense.

(On a side note: I didn't create this issue, just submitted a PR - you seemed to reference me when replying to @sijk)