2

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!

4

1 回答 1

3

您说得对,这里的问题是 SSH 身份验证。

当 cronjob 运行时,它必须以某种方式访问​​您的 Bitbucket 存储库。您选择使用使用 SSH 的“git”协议。使用 SSH 时,使用基于密钥的身份验证比使用密码要好得多——而对于 git repos,它在大多数情况下是唯一的方式,具体取决于主机。

您可以将您的私钥放在该 cron 服务器上以访问 Bitbucket(可能是一个坏主意),或者您创建一个新的密钥对并使用它来允许访问您的存储库(更好,除非您遇到一些限制bitbucket 帐户,如果该密钥算作用户,则像太多用户 - 另一方面,您可以将此密钥限制为仅允许读取,而不是写入)。

确保用于运行您的 cronjob 的用户正在使用这些密钥,例如,您应该能够在没有任何代理的情况下手动启动脚本,并且它应该在不询问密码的情况下完成。私钥的正确位置是~/.ssh,公钥转到 Bitbucket。之后,一切都应该在 cronjob 中完美运行。

另一种方法可能是使用不同的协议(如 HTTPS)进行 repo 访问,看看会发生什么。

于 2013-10-09T18:35:40.843 回答