I'm trying to pull a private package hosted on Bitbucket into my project but I can't seem to get composer to work correctly with my SSH key.
I'm currently trying:
{
"type": "composer",
"url": "https://packagist.org"
},
{
"type": "vcs",
"url": "git@bitbucket.org:{projectName}/{repo}.git",
"ssh2": {
"username": "git",
"privkey_file": "/home/vagrant/.ssh/bitbucket_id_rsa",
"pubkey_file": "/home/vagrant/.ssh/bitbucket_id_rsa.pub"
}
},
When I try to run composer update I get Permission denied (publickey) but when I run ssh -T git@bitbucket.org -i /home/vagrant/.ssh/bitbucket_id_rsa I can connect successfully.
I'm not sure if its even attempting to use the key specified because if I type random letters in the priv and pub key options, it still fails in the same way instead of throwing a file not found.
Hoping its just a small configuration error I've made as I'm not too sure what's wrong with it.
You are using the ssh2 options where they don't belong. That key belongs inside the options key. E.g.:
{
"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"
}
}
}]
}
Located where they are, it's not a big surprise composer is simply ignoring those settings.
Still, I'm not sure this is going to do what you need to authenticate with bitbucket. If you have a private bitbucket repo, you should probably use the bitbucket driver:
{
"config": {
"bitbucket-oauth": {
"bitbucket.org": {
"consumer-key": "myKey",
"consumer-secret": "mySecret"
}
}
}
}
来源:https://stackoverflow.com/questions/46934742/using-an-ssh-key-with-composer-for-a-private-vcs