Deployer: Bug - can ssh in terminal but deployer reporting 'ssh' is not recognized as an internal or external command, operable program or batch file.

Created on 5 Oct 2018  Â·  24Comments  Â·  Source: deployphp/deployer

| Q | A
| ----------------- | ---
| Issue Type | Bug, Question, Feature Request
| Deployer Version | 6.3
| Local Machine OS | Windows 10
| Remote Machine OS | Ubuntu 18.04

Description

If you're reporting a bug, please include following information

Steps to reproduce

runningvendor\bin\dep deploy -vvv on windows with ssh support
When I ssh on command prompt, there is ssh help message. But deployer seems to not see ssh.

Content of deploy.php

<?php
namespace Deployer;

require 'recipe/laravel.php';

// Project name
set('application', REMOVED);
set('default_stage', 'staging');


// Project repository
set('repository', REMOVED);

// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true); 

// Shared files/dirs between deploys 
add('shared_files', []);
add('shared_dirs', []);

// Writable dirs by web server 
add('writable_dirs', []);


// Hosts

host('production')
    ->hostname(REMOVED)
    ->port(25560)
    ->set('deploy_path', '/var/www/{{application}}');

host('staging')
    ->hostname(REMOVED)
    ->port(25560)
    ->set('deploy_path', '/var/www/staging_{{application}}');

// Tasks

task('build', function () {
    run('cd {{release_path}} && build');
});

// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');

// Migrate database before symlink new release.

before('deploy:symlink', 'artisan:migrate');

Output log

With enabled option for verbose output -vvv.

vendorbindep deploy -vvv

[localhost] > git rev-parse --abbrev-ref HEAD
[localhost] < Development
✈︎ Deploying Development on staging
• done on [staging]
➤ Executing task deploy:prepare
[staging] > echo $0
[staging] < ssh multiplexing initialization
[staging] < 'ssh' is not recognized as an internal or external command,
[staging] < operable program or batch file.
➤ Executing task deploy:failed
• done on [staging]
✔ Ok [1ms]
➤ Executing task deploy:unlock
[staging] > rm -f /var/www/REMOVED/.dep/deploy.lock
[staging] < ssh multiplexing initialization
[staging] < 'ssh' is not recognized as an internal or external command,
[staging] < operable program or batch file.

In Client.php line 99:

[DeployerExceptionRuntimeException (-1)]
The command "rm -f /var/www/REMOVED/.dep/deploy.lock" failed.

Exit Code: -1 (Unknown error)

Host Name: staging

================
'ssh' is not recognized as an internal or external command,
operable program or batch file.

Exception trace:
DeployerSshClient->run() at REMOVEDvendordeployerdeployersrcfunctions.php:304
Deployerrun() at REMOVEDvendordeployerdeployerrecipedeploylock.php:30
DeployerDeployer::Deployer{closure}() at n/a:n/a
call_user_func() at REMOVEDvendordeployerdeployersrcTaskTask.php:105
DeployerTaskTask->run() at REMOVEDvendordeployerdeployersrcExecutorSeriesExecutor.php:63
DeployerExecutorSeriesExecutor->run() at REMOVEDvendordeployerdeployersrcConsoleTaskCommand.php:155
DeployerConsoleTaskCommand->execute() at REMOVEDvendorsymfonyconsoleCommandCommand.php:255
SymfonyComponentConsoleCommandCommand->run() at REMOVEDvendorsymfonyconsoleApplication.php:948
SymfonyComponentConsoleApplication->doRunCommand() at REMOVEDvendordeployerdeployersrcConsoleApplication.php:133
DeployerConsoleApplication->doRunCommand() at REMOVEDvendorsymfonyconsoleApplication.php:250
SymfonyComponentConsoleApplication->doRun() at REMOVEDvendorsymfonyconsoleApplication.php:148
SymfonyComponentConsoleApplication->run() at REMOVEDvendordeployerdeployersrcDeployer.php:331
DeployerDeployer::run() at REMOVEDvendordeployerdeployerbinmd5-38fdb0b9dbd45c12d625b532baecaf3edep:120

deploy [-p|--parallel] [-l|--limit LIMIT] [--no-hooks] [--log LOG] [--roles ROLES] [--hosts HOSTS] [-o|--option OPTION] [--] []

All 24 comments

Check what your local system has ssh installed.

My ssh is installed in C:\Windows\System32\OpenSSH\ssh.exe
Version is OpenSSH_for_Windows_7.6p1, LibreSSL 2.6.4

Is the ssh command with $PATH ?

yes it is in PATH, and i can directly call ssh in terminal anywhere

It seems its not accessible to your php cli

What can i do to test it?

Maybe php -r 'echo exec("ssh -v");' from your cli

Just guessing..

There is no output

Missed a echo, just added it above

PHP Parse error:  syntax error, unexpected ''echo' (T_ENCAPSED_AND_WHITESPACE), expecting end of file in Command line code on line 1

Parse error: syntax error, unexpected ''echo' (T_ENCAPSED_AND_WHITESPACE), expecting end of file in Command line code on line 1

Semicolon on the wrong place... another edit above

Still not working. I tried php -a to get into interactive mode and ran echo exec("ssh -v");, it confirms that php can't access ssh. 'ssh' is not recognized as an internal or external command, operable program or batch file. Is there a way to let php access ssh

Usually just set the $PATH variable correctly

I’m quite sure that my $PATH is set correctly

Check user/group on ssh bin.

Can user you are running from.

I'm running on windows. Windows doesn't have the user/group permission problem

Try windows subsystem for ubuntu

The main problem is that php can't ssh while I can in command prompt. I also tried other commands like git in php and it works flawlessly. Not sure what it is all about.

Can't tell too. I need your machine to investigate :)

I did some more investigation, it seems that in php, it doesn't see some directories. like OpenSSH in WindowsSystem32. Very Weird.....

I think this may be a issue with php and Windows 10. Closing the issue.

The reason that ssh can't be called is because XAMPP uses 32bit version of php, and exec in 32bit php uses cmd in C:\Windows\SysWOW64 which somehow doesn't have ssh. The solution is to use 64 bit php.

The reason that ssh can't be called is because XAMPP uses 32bit version of php, and exec in 32bit php uses cmd in C:\Windows\SysWOW64 which somehow doesn't have ssh. The solution is to use 64 bit php.

@danielpclin Just thought you should know, this comment really helped me out. Thank you.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krve picture krve  Â·  4Comments

k-solnushkin picture k-solnushkin  Â·  5Comments

minkbear picture minkbear  Â·  4Comments

greatwitenorth picture greatwitenorth  Â·  4Comments

ElForastero picture ElForastero  Â·  3Comments