trilbymedia / grav-plugin-git-sync

Collaboratively Synchronize your Grav `user` folder hosted on GitHub, BitBucket or GitLab
Apache License 2.0
243 stars 58 forks source link

Support for SSH keys #110

Closed baurmatt closed 3 years ago

baurmatt commented 5 years ago

Please support SSH keys additional to login credentials. This is especially helpful for Gitlab Enterprise installations where every user cost money.

Thanks in advance!

w00fz commented 5 years ago

I looked into supporting ssh keys but it is quite a bit more complicated than I anticipated.

The main problem is that executed git commands from PHP are not able to read the .ssh/config (IdentityFile). In order to do this it requires a good chunk of code to be rewritten, perhaps by tapping into symfony/process instead of using the exec method.

I am open for this but for a future version, not at this moment, sorry.

fralau commented 5 years ago

Could this help?

https://packagist.org/packages/pagemachine/authorized-keys

I guess however, that would require generating a key pair for the app, and storing it. This would also require encrypting the private key, with some secret password (but this should not be so different than storing an ordinary ssh password securely and retrieving it).

w00fz commented 5 years ago

Actually I did some extra digging and turns out i couldn’t get it working because my key had a passphrase. That’s what’s not supported as well as how I parse the urls. With a no-password passphrase I will be able to add support for keys and I’m planning to do so. I did a quick testing on another project and works flawlessly!

I might not be able to add this on the next upcoming release but i will definitely look into adding support for it in the near future.

OleVik commented 5 years ago

I would second key-auth, or at least configuration that can live alongside or supersede the global git-config. I'm getting into the habit of signing all commits, and so the global setting forces me to sign every change that GitSync captures -- which fails with a gpg: AllowSetForegroundWindow(6216) failed: Access is denied. gpg: signing failed: Card error gpg: signing failed: Card error error: gpg failed to sign the data fatal: failed to write commit object.

draeath commented 5 years ago

I'd love to see this... we're trying to use Azure and personal access tokens have an enforced expiration date of no later than a year.

ntopulos commented 5 years ago

That would be great! Using GitHub's deploy keys is a much more secure approach than to give a plugin access to all our repositories. On some projects I couldn't use this plugin at all for that reason: giving the credentials of a real user is out of the question, and creating a dedicated user is not always possible.

Is this feature still under consideration/development? Is any help needed?

w00fz commented 5 years ago

Thanks for the feedbacks, this feature is definitely still under consideration and will be implemented for next release. I’m just very busy lately and can’t look at this right away.

Please note that my statement above still stand: this feature will support keys ONLY if they aren’t created with a passphrase. I just have no way of getting around that. 🙂

ntopulos commented 5 years ago

Happy to hear that!

I understand, and to my knowledge SSH keys with passwords are unsupported by most of automation tools.

w00fz commented 3 years ago

Thought you guys would be happy to know I have added support for SSH Keys.

You can read more about it here: https://github.com/trilbymedia/grav-plugin-git-sync#ssh--enterprise


w00fz-2021-04-27_@_11 46 46@2x
baurmatt commented 3 years ago

Awesome, thank you very much! :)