I was trying to get a private repository from Github installed via composer
. My composer
configuration is as below:
"repositories": [
{
"type": "vcs",
"url": "[email protected]:{user}/{repo}.git",
"options": {
"ssh2": {
"user": "ranacseruet"
"privkey_file": "./keys/id_rsa",
"pubkey_file": "./keys/id_rsa.pub"
}
}
}
]
However, it doesn't work with this configuration. It's still asking for github user/pass. However, if my system's github authorization is set up properly with keys, only then it works automatically.
In any way, composer configuration isn't working. Is anybody else facing the same issue or is there anything I did wrong/need to check here? Thanks in advance.
I'm not sure what your problem is, but you could solve it another way using an ssh config file.
This allows you to configure SSH connections to use specific credentials for 'virtual' hosts, which thus allows you to alter the way you connect to Git repos, and therefore can be used to modify Composer dependencies which use ssh.
Edit ~/.ssh/config e.g.
Host ranacseruet_github.com
User git
HostName github.com
IdentityFile [path-to]/keys/id_rsa
Then modify your composer.json to use the fake host and remove the ssh options:
"repositories": [
{
"type": "vcs",
"url": "git@ranacseruet_github.com:{user}/{repo}.git",
}
]
So when ssh tries to connect to the 'virtual' host ranacseruet_github.com, it will use the credentials specified.
I use this technique to define git remotes which need specific credentials. It should work exactly the same via composer, as it is a more general solution at the ssh-level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With