Severin Severin - 3 months ago 47
PHP Question

Magallanes deploy unable to connect via ssh key

I am trying to deploy a Symfony2 PHP project on Ubuntu 15.10 with MagePHP, but it always asks me for the SSH users password when executing:

sudo php vendor/andres-montanez/magallanes/bin/mage deploy to:staging


When checking the log I can see it stops at this command:

ssh -p 22 -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ssh-user@my-domain.com "sh -c \"mkdir -p /customers/489176_10999/websites/my_company/symfony/staging/releases/20160902094526\""


Executing this command by itself works fine (so the server accepts the ssh key), but from within the context of the deployment script it doesn't.

I am quite puzzled by this, since both commands are run from the same directory. Any ideas how I can make this work?

Answer

Since the file has been located under /var/www the ssh-agent had no access to the key files, since they were stored under the user directory. Moving the entire project inside the user directory fixed this issue.