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?

2 Answers 2


You 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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .