Question

I'm try to update my private repository via a cron job but nothing seems to be happening. I'm using Satis to create the repository for my private packages.

I can do this manually by logging into my account via SSH and running:

php bin/satis build satis.json ./ -n

which updates everything fine apart from I have to enter my passphrase a million times. I can get round this by using SSH Agent and think this may be my problem...

php /home/accountname/public_html/bin/satis build /home/accountname/public_html/satis.json /home/accountname/public_html/ -n

Is there anything I'm missing?

UPDATE

It is the SSH auth as I've received this error via email (shortened version)

Reading composer.json of vendor/package (master)
Failed to update git@bitbucket.org:vendor/package.git, package information from this repository may be outdated (Permission denied (publickey). fatal: The remote end hung up unexpectedly error: Could not fetch origin )

In the docs it says about using -n to use the SSH Key but I am using it.

Any ideas?

UPDATE

Thought I would add my satis file structure:

{
    "name": "Name Of My Repo",
    "homepage": "http://repodomain.co.uk",
    "repositories": [
        { "type": "vcs", "url": "git@bitbucket.org:vendor/package.git" }
    ],
    "require-all": true
} 

really stuck on this one, the documentation is crap!

Was it helpful?

Solution

You are right that the SSH authentication is the problem here.

When the cronjob is running, it must access your Bitbucket repository somehow. You chose to use the "git" protocol, which uses SSH. When using SSH, using key-based authentication is way better than using passwords - and when it comes to git repos, it is the only way most of the time depending on the hosting.

Either you put your private key onto that cron server to get access to Bitbucket (might be a bad idea), or you create a new key pair and use that to allow access for your repo (is better, unless you experience some limitations of your bitbucket account, like too many users if that key counts as a user - on the other hand you could limit this key to be only allowed to read, not write).

Make sure that the user that is used to run your cronjob is using these keys, e.g. you should be able to manually start the script without any agent, and it should finish without asking for passwords. The correct place for the private key is ~/.ssh, the public key goes to Bitbucket. After that everything should run perfectly in the cronjob.

The other way could be to use a different protocol (like HTTPS) for the repo access and see what happens.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top