phpgitsshcomposer-phpgitblit

authenticate private vcs with specific user


I'm using gitblit to self-host my git repositories. I added them to my composer file:

"repositories": [
    {
        "type": "vcs",
        "url": "ssh://user@my.gitblit.com:29418/foo/repo.git"
    }
]

It works well except I'm asked for the password for every of those repos. I wonder how I authenticate. I see that I can enter username, password but not for git. I see that I can authenticate with keys but the user running the install/update command is www-data and not user who has rights to read the repositories.

How do I authenticate to this so I can run composer unattended?


Solution

  • You can tell composer what key to use for each repository.

    From the doc :

    {
      "repositories": [{
        "type": "composer",
        "url": "ssh2.sftp://example.org",
        "options": {
          "ssh2": {
            "username": "composer",
            "pubkey_file": "/home/composer/.ssh/id_rsa.pub",
            "privkey_file": "/home/composer/.ssh/id_rsa"
          }
        }
      }]
    }