Deployer: Deploying under Proxy

Created on 1 Jun 2016  Â·  12Comments  Â·  Source: deployphp/deployer

| Q | A |
| --- | --- |
| Issue Type | Question |
| Deployer Version | 3.3.0 |
| Local Machine OS | Windows |
| Remote Machine OS | Debian |

Description

I'm trying to use Deplyer, but when I use the command php deployer.phar deploy preprodI get a `Ùnable to login with the provided credentials.``error.
I can connect in SSH with those credentials (using Putty), and I also used Capifony before, which I had to use with this config to pass through the proxy

require 'net/ssh/proxy/http'
sshproxy = Net::SSH::Proxy::HTTP.new('YY.YY.YY.YYY', 8080)
set :ssh_options, { :proxy => sshproxy }
ssh_options[:forward_agent] = true

Is it possible to do this with Deployer ?

Content of deploy.php

<?php
require 'recipe/symfony.php';

server('preprod', 'XX.XX.XX.XXX')
    ->user('myusername')
    ->password('mypassword')
    ->stage('production')
    ->env('deploy_path', '/var/www/XXX/www');

// Specify the repository from which to download your project's code.
set('repository', 'https://bitbucket.org/XXX/XXX.git');

Output log

C:\wamp\www\XXX>php deployer.phar deploy preprod -vvv
Ô×ñ Executing task deploy:prepare
Ôå│ on [preprod]

Notice: Cannot connect to XX.XX.XX.XXX:22. Error 10060. Une tentative de connexion a ÚchouÚ car le parti connectÚ nÆa pas rÚpondu convenablement au-delÓ dÆune certaine durÚe ou une connexion Útablie
a ÚchouÚ car lÆh¶te de connexion nÆa pas rÚpondu. in phar://C:/wamp/www/XXX/deployer.phar/vendor/phpseclib/phpseclib/phpseclib/Net/SSH2.php on line 1011

  [RuntimeException]
  Unable to login with the provided credentials.

Exception trace:
 () at phar://C:/wamp/www/XXX/deployer.phar/src/Server/Remote/PhpSecLib.php:99
 Deployer\Server\Remote\PhpSecLib->connect() at phar://C:/wamp/www/XXX/deployer.phar/recipe/common.php:105
 {closure}() at n/a:n/a
 call_user_func() at phar://C:/wamp/www/XXX/deployer.phar/src/Task/Task.php:79
 Deployer\Task\Task->run() at phar://C:/wamp/www/XXX/deployer.phar/src/Executor/SeriesExecutor.php:43
 Deployer\Executor\SeriesExecutor->run() at phar://C:/wamp/www/XXX/deployer.phar/src/Console/TaskCommand.php:82
 Deployer\Console\TaskCommand->execute() at phar://C:/wamp/www/XXX/deployer.phar/vendor/symfony/console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at phar://C:/wamp/www/XXX/deployer.phar/vendor/symfony/console/Application.php:791
 Symfony\Component\Console\Application->doRunCommand() at phar://C:/wamp/www/XXX/deployer.phar/vendor/symfony/console/Application.php:186
 Symfony\Component\Console\Application->doRun() at phar://C:/wamp/www/XXX/deployer.phar/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar://C:/wamp/www/XXX/deployer.phar/src/Deployer.php:101
 Deployer\Deployer->run() at phar://C:/wamp/www/XXX/deployer.phar/bin/dep:63
 require() at C:\wamp\www\XXX\deployer.phar:4

deploy [-p|--parallel]

Most helpful comment

Not cool that you closed the issue, it's not solved at all...

All 12 comments

Your problem:

Your machine     ==SSH==>    Proxy server    ==SSH==>       Deploy Server

With:

| Proxy Server | Deploy Server |
| --- | --- |
| xxx.xxx.xxx.xxx:8080 | yyy.yyy.yyy.yyy:22 |

@oanhnn Is this an answer ?

@picks44 I want confirm your problem to find solution.
I am not sure but you should try add ssh proxy to a ssh config file and using config file method for authentication with ext-ssh2

| | Proxy Server | Deploy Server |
| --- | --- | --- |
| IP | xxx.xxx.xxx.xxx | yyy.yyy.yyy.yyy |
| Port | 22 | 22 |
| User | user1 | user2 |
| Key | key/id_rsa | key/id_rsa |

# ssh config file on your machine
Host yyy.yyy.yyy.yyy
    Hostname yyy.yyy.yyy.yyy
    IdentityFile ~/.ssh/id_rsa
    ProxyCommand ssh -q -W %h:%p [email protected]
    ForwardAgent yes
# deploy.php
<?php
require 'recipe/symfony.php';
set('ssh_type', 'ext-ssh2');
server('preprod', 'XX.XX.XX.XXX')
    ->user('user2')
    ->configFile('path/to/.ssh/config')
    ->stage('production')
    ->env('deploy_path', '/var/www/XXX/www');

// Specify the repository from which to download your project's code.
set('repository', 'https://bitbucket.org/XXX/XXX.git');
$ ssh-add key/id_rsa
$ bin/dep deploy production -vvv

Hello @oanhnn,

So far my ssh_config looked like this

Host *
    ProxyCommand connect %h %p
    ForwardAgent yes

Host yyy.yyy.yyy.yyy
    IdentityFile ~/.ssh/key.ppk
    ProxyCommand connect -H xxx.xxx.xxx.xxx:8080 %h 443

I've tried your solution, but I get this error

C:\wamp\www\XXX>php deployer.phar deploy preprod -vvv
Ô×ñ Executing task deploy:prepare
Ôå│ on [preprod]


  [RuntimeException]
  You need to specify authentication method.


Exception trace:
 () at phar://C:/wamp/www/XXX/deployer.phar/src/Server/Remote/PhpSecLib.php:95
 Deployer\Server\Remote\PhpSecLib->connect() at phar://C:/wamp/www/XXX/deployer.phar/recipe/common.php:105
 {closure}() at n/a:n/a
 call_user_func() at phar://C:/wamp/www/XXX/deployer.phar/src/Task/Task.php:79
 Deployer\Task\Task->run() at phar://C:/wamp/www/XXX/deployer.phar/src/Executor/SeriesExecutor.php:43
 Deployer\Executor\SeriesExecutor->run() at phar://C:/wamp/www/XXX/deployer.phar/src/Console/TaskCommand.php:82
 Deployer\Console\TaskCommand->execute() at phar://C:/wamp/www/XXX/deployer.phar/vendor/symfony/console/Command/Command.php:256
 Symfony\Component\Console\Command\Command->run() at phar://C:/wamp/www/XXX/deployer.phar/vendor/symfony/console/Application.php:791
 Symfony\Component\Console\Application->doRunCommand() at phar://C:/wamp/www/XXX/deployer.phar/vendor/symfony/console/Application.php:186
 Symfony\Component\Console\Application->doRun() at phar://C:/wamp/www/XXX/deployer.phar/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar://C:/wamp/www/XXX/deployer.phar/src/Deployer.php:101
 Deployer\Deployer->run() at phar://C:/wamp/www/XXX/deployer.phar/bin/dep:63
 require() at C:\wamp\www\XXX\deployer.phar:4

deploy [-p|--parallel]

@picks44
You have use ext-ssh2. Please install php extention ssh2 and add a line to deploy.php

require 'recipe/symfony.php';
set('ssh_type', 'ext-ssh2'); // <= add this line
server('preprod', 'XX.XX.XX.XXX')
    ->user('user2')
    ->configFile('path/to/.ssh/config')
    ->stage('production')
    ->env('deploy_path', '/var/www/XXX/www');

// Specify the repository from which to download your project's code.
set('repository', 'https://bitbucket.org/XXX/XXX.git');

@oanhnn

New error

Warning: ssh2_connect(): Unable to connect to XX.XX.XX.XXX on port 22 in phar://C:/wamp/www/XXX/deployer.phar/vendor/herzult/php-ssh/src/Ssh/Session.php on line 153

Warning: ssh2_connect(): Unable to connect to XX.XX.XX.XXX in phar://C:/wamp/www/XXX/deployer.phar/vendor/herzult/php-ssh/src/Ssh/Session.php on line 153

  Shell on your server is not POSIX-compliant. Please change to sh, bash or similar.
  Usually, you can change your shell to bash by running: chsh -s /bin/bash

  [RuntimeException]
  The SSH connection failed.

@oanhnn any help on this ?

Shell on your server is not POSIX-compliant. Please change to sh, bash or similar.
Usually, you can change your shell to bash by running: chsh -s /bin/bash

@elfet I used the command above, and echo $SHELL on my server returns /bin/bash but I still have the same error.
If it helps, I'm using the deployer.phar on a Windows 7 machine. My php_ssh2 extension is active.

@picks44 Please check your ssh proxy command

@oanhnn here it is again, I don't see what could be wrong in it.

Host XX.XX.XX.XXX
    Hostname XX.XX.XX.XXX
    IdentityFile ~/.ssh/key.ppk
    ProxyCommand connect -H YY.YY.YY.YYY:8080 %h 443
    ForwardAgent yes

Not cool that you closed the issue, it's not solved at all...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chouex picture chouex  Â·  4Comments

ElForastero picture ElForastero  Â·  3Comments

khoanguyen96 picture khoanguyen96  Â·  5Comments

brunodevel picture brunodevel  Â·  3Comments

minkbear picture minkbear  Â·  4Comments