I'm using crontab for synchronizing git repositories. I was able to do operations like git add and commit, but can't perform git push to origin, since every git push asks for a password.
How can I connect to the server using git push using cron?
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityYou can use git
over different transport methods.
It is common to access a remote git repository over a ssh
connection.
And with ssh you can configure public-key-authentication, which is password-less (when your private-key has no password set).
It is recommended to generate new ssh-key-pairs for different remote destinations - and depending on if you need password-less access or not you can decide whether to protect the private-key with a password or not (the password would only be used to locally decrypt the private-key during authentication).
See for example the ssh-notes of the github team.
Followup to maxschlepzig
Better way may be push not from cron, but in post-commit hook (less useless operations, you can enter password on request)