Deployer: Can not use forwardAgent() on Windows

Created on 12 Oct 2016  路  5Comments  路  Source: deployphp/deployer

I have commented on perfectly correct issue, that was although closed for no reason. Got reply "create a new report" and thought devs are dead. Since now, 1.5 years later, original issue was reopened, looks like devs are still alive somehow, I might as well follow that advice and create new issue for the same bug:

| Q | A |
| --- | --- |
| Issue Type | Bug |
| Deployer Version | v3.3.0 |
| Local Machine OS | windows 10 (tested windows 8 as well, no difference) |
| Remote Machine OS | ubuntu 16.04 |

Description

_Deploy with password, or with ssh keys+passphrases works ok, fails if trying to use forwardAgent() instead. It fails only on windows, it works ok in linux->linux situation._

Steps to reproduce

  1. Run Windows
  2. Try to deploy from windows using forwardAgent()
  3. You fail.

    Content of deploy.php

require_once __DIR__.'/vendor/autoload.php';
use \Symfony\Component\Console\Output\OutputInterface;
use \Symfony\Component\Console\Input\InputArgument;
use \Symfony\Component\Console\Input\InputOption;

//argument();
//option();

require_once 'recipe/common.php';



//
// Set configurations.
//
set('repository', '[email protected]:test/test.git');
set('shared_files', []);
set('shared_dirs', [
    'www/wp-content/uploads',
    ]);
set('keep_releases', 3);

env('timezone', 'Europe/Moscow');
set('default_stage', $default_stage ?? 'prod');



//
// Configure servers.
//
server($site_name = 'example.com', '192.168.1.3')
    ->env('deploy_path', "/var/www/$site_name")
    ->env('site_name', $site_name)
    ->stage('prod')
    ->user('deploy')
    ->forwardAgent();

Output log

_With enabled option for verbose output -vvv._

dep c -vvv
褌挟写 Executing task current
褌袞娄 on [example.com]
> cd /var/www/example.com && readlink /var/www/example.com/current

Warning: fsockopen(): unable to connect to unix:///tmp/.ssh-socket:0 (Unable to find the socket transport "unix" - did you forget to enable it when you configured PHP?) in C:\wamp64\www\example.com\vendor\phpseclib\phpseclib\phpseclib\System\SSH\Agent.php on line 134

Call Stack:
    0.0002     364600   1. {main}() C:\wamp64\www\example.com\vendor\deployer\deployer\bin\dep:0
    0.0261    3074016   2. Deployer\Deployer->run() C:\wamp64\www\example.com\vendor\deployer\deployer\bin\dep:64
    0.0304    3262088   3. Symfony\Component\Console\Application->run() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Deployer.php:101
    0.0304    3262088   4. Symfony\Component\Console\Application->doRun() C:\wamp64\www\example.com\vendor\symfony\console\Application.php:117
    0.0305    3262088   5. Symfony\Component\Console\Application->doRunCommand() C:\wamp64\www\example.com\vendor\symfony\console\Application.php:186
    0.0305    3262088   6. Symfony\Component\Console\Command\Command->run() C:\wamp64\www\example.com\vendor\symfony\console\Application.php:818
    0.0308    3264880   7. Deployer\Console\TaskCommand->execute() C:\wamp64\www\example.com\vendor\symfony\console\Command\Command.php:256
    0.0313    3279984   8. Deployer\Executor\SeriesExecutor->run() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Console\TaskCommand.php:82
    0.0363    3312816   9. Deployer\Task\Task->run() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Executor\SeriesExecutor.php:43
    0.0363    3313136  10. call_user_func:{C:\wamp64\www\example.com\vendor\deployer\deployer\src\Task\Task.php:79}() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Task\Task.php:79
    0.0363    3313136  11. {closure:C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:405-407}() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Task\Task.php:79
    0.0363    3313168  12. env() C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:406
    0.0363    3313168  13. Deployer\Server\Environment->get() C:\wamp64\www\example.com\vendor\deployer\deployer\src\functions.php:573
    0.0364    3313168  14. call_user_func:{C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Environment.php:101}() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Environment.php:101
    0.0364    3313168  15. {closure:C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:398-400}() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Environment.php:101
    0.0364    3313232  16. run() C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:399
    0.0372    3313264  17. Deployer\Server\Remote\PhpSecLib->run() C:\wamp64\www\example.com\vendor\deployer\deployer\src\functions.php:296
    0.0372    3313264  18. Deployer\Server\Remote\PhpSecLib->checkConnection() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:118
    0.0372    3313264  19. Deployer\Server\Remote\PhpSecLib->connect() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:109
    0.0427    4631824  20. phpseclib\System\SSH\Agent->__construct() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:78
    0.0427    4631920  21. fsockopen() C:\wamp64\www\example.com\vendor\phpseclib\phpseclib\phpseclib\System\SSH\Agent.php:134


Notice: Unable to connect to ssh-agent (Error 0: Unable to find the socket transport "unix" - did you forget to enable it when you configured PHP?) in C:\wamp64\www\example.com\vendor\phpseclib\phpseclib\phpseclib\System\SSH\Agent.php on line 136

Call Stack:
    0.0002     364600   1. {main}() C:\wamp64\www\example.com\vendor\deployer\deployer\bin\dep:0
    0.0261    3074016   2. Deployer\Deployer->run() C:\wamp64\www\example.com\vendor\deployer\deployer\bin\dep:64
    0.0304    3262088   3. Symfony\Component\Console\Application->run() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Deployer.php:101
    0.0304    3262088   4. Symfony\Component\Console\Application->doRun() C:\wamp64\www\example.com\vendor\symfony\console\Application.php:117
    0.0305    3262088   5. Symfony\Component\Console\Application->doRunCommand() C:\wamp64\www\example.com\vendor\symfony\console\Application.php:186
    0.0305    3262088   6. Symfony\Component\Console\Command\Command->run() C:\wamp64\www\example.com\vendor\symfony\console\Application.php:818
    0.0308    3264880   7. Deployer\Console\TaskCommand->execute() C:\wamp64\www\example.com\vendor\symfony\console\Command\Command.php:256
    0.0313    3279984   8. Deployer\Executor\SeriesExecutor->run() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Console\TaskCommand.php:82
    0.0363    3312816   9. Deployer\Task\Task->run() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Executor\SeriesExecutor.php:43
    0.0363    3313136  10. call_user_func:{C:\wamp64\www\example.com\vendor\deployer\deployer\src\Task\Task.php:79}() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Task\Task.php:79
    0.0363    3313136  11. {closure:C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:405-407}() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Task\Task.php:79
    0.0363    3313168  12. env() C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:406
    0.0363    3313168  13. Deployer\Server\Environment->get() C:\wamp64\www\example.com\vendor\deployer\deployer\src\functions.php:573
    0.0364    3313168  14. call_user_func:{C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Environment.php:101}() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Environment.php:101
    0.0364    3313168  15. {closure:C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:398-400}() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Environment.php:101
    0.0364    3313232  16. run() C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:399
    0.0372    3313264  17. Deployer\Server\Remote\PhpSecLib->run() C:\wamp64\www\example.com\vendor\deployer\deployer\src\functions.php:296
    0.0372    3313264  18. Deployer\Server\Remote\PhpSecLib->checkConnection() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:118
    0.0372    3313264  19. Deployer\Server\Remote\PhpSecLib->connect() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:109
    0.0427    4631824  20. phpseclib\System\SSH\Agent->__construct() C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:78
    0.1273    4633728  21. user_error() C:\wamp64\www\example.com\vendor\phpseclib\phpseclib\phpseclib\System\SSH\Agent.php:136



  [RuntimeException]
  Unable to login with the provided credentials.


Exception trace:
 () at C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:99
 Deployer\Server\Remote\PhpSecLib->connect() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:109
 Deployer\Server\Remote\PhpSecLib->checkConnection() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Remote\PhpSecLib.php:118
 Deployer\Server\Remote\PhpSecLib->run() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\functions.php:296
 run() at C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:399
 {closure}() at n/a:n/a
 call_user_func() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\Server\Environment.php:101
 Deployer\Server\Environment->get() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\functions.php:573
 env() at C:\wamp64\www\example.com\vendor\deployer\deployer\recipe\common.php:406
 {closure}() at n/a:n/a
 call_user_func() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\Task\Task.php:79
 Deployer\Task\Task->run() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\Executor\SeriesExecutor.php:43
 Deployer\Executor\SeriesExecutor->run() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\Console\TaskCommand.php:82
 Deployer\Console\TaskCommand->execute() at C:\wamp64\www\example.com\vendor\symfony\console\Command\Command.php:256
 Symfony\Component\Console\Command\Command->run() at C:\wamp64\www\example.com\vendor\symfony\console\Application.php:818
 Symfony\Component\Console\Application->doRunCommand() at C:\wamp64\www\example.com\vendor\symfony\console\Application.php:186
 Symfony\Component\Console\Application->doRun() at C:\wamp64\www\example.com\vendor\symfony\console\Application.php:117
 Symfony\Component\Console\Application->run() at C:\wamp64\www\example.com\vendor\deployer\deployer\src\Deployer.php:101
 Deployer\Deployer->run() at C:\wamp64\www\example.com\vendor\deployer\deployer\bin\dep:64

c [-p|--parallel]

research

Most helpful comment

Problem with ssh in php is what native extension ext-ssh for php does not support this, and pure php implementation of ssh (phpseclib) supports it only on unix-like systems.

So here a few way to solve this issue:

  • Implement forwardAgent in ext-ssh.
  • Add windows support to phpseclib.
  • Or add new ssh transport to deployer.

I'm going to do last one in next v4. But do not know then it will be done.

All 5 comments

Problem with ssh in php is what native extension ext-ssh for php does not support this, and pure php implementation of ssh (phpseclib) supports it only on unix-like systems.

So here a few way to solve this issue:

  • Implement forwardAgent in ext-ssh.
  • Add windows support to phpseclib.
  • Or add new ssh transport to deployer.

I'm going to do last one in next v4. But do not know then it will be done.

Thanks for explanation. Will be happy to test any time. I really hope it can be any time soon.

I'll be beta-tester if you need.

Native ssh in v4. Closing.

Cool news! Just found out you're a creator on Patreon. I am happy to become your first supporter. If you keep putting those useful features on the roadmap you'll get all the money you need for sure!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brunodevel picture brunodevel  路  3Comments

osbulbul picture osbulbul  路  3Comments

greatwitenorth picture greatwitenorth  路  4Comments

minkbear picture minkbear  路  4Comments

ovaiskhan11 picture ovaiskhan11  路  4Comments