ftp-deployment icon indicating copy to clipboard operation
ftp-deployment copied to clipboard

Unable to exchange encryption keys

Open vosykapavel opened this issue 2 years ago • 1 comments

Version: 3.4.0 | 3.5.2 (upgrade didn't help)

Bug Description

SFTP connection (login+password, no keys) stopped working with one client server (other SFTP connections works well) in Gitlab CI.

I was using this image (petrnemec/ftp-deployment:latest, same error with php:7.4-cli and php:8.1.7-cli) Last working: Apr 7, 2022 First not working: Jun 2, 2022

Error message: Error starting up SSH connection(-5): Unable to exchange encryption keys

The client probably changed some configuration.

I got the same error locally with PHP 7.4.30 (on windows). Error starting up SSH connection(-5): Unable to exchange encryption keys

And I got this error locally with PHP 8.1.2 | 8.1.7 (on windows) Error: file_get_contents(): Read of 8192 bytes failed with errno=13 Permission denied in phar://C:/www/project/deployment.phar/src/Deployment/Helpers.php:2

(SSH2 is always loaded)

Expected Behavior

It should work. :-)

Possible Solution

I tried this PHP script with locally cli (with PHP 8.1.2). And connection was ok - it listed the server directory. So, maybe I have wrong ftp/deployment config, or there is an issue in the deployment app (for some SFTP configurations).

Can you help?

<?php
// testftp.php
//phpinfo();

function scanFilesystem($dir) {
    $tempArray = array();
    $handle = opendir($dir);
    // List all the files
    while (false !== ($file = readdir($handle))) {
        if (substr("$file", 0, 1) != "."){
            if(is_dir($file)){
                $tempArray[$file]=scanFilesystem("$dir/$file");
            } else {
                $tempArray[]=$file;
            }
        }
    }
    closedir($handle);
    return $tempArray;
}

$connection = ssh2_connect('ftp.project.xx', 22);
ssh2_auth_password($connection, 'xxx', 'xxx');

$sftp = ssh2_sftp($connection);

//$stream = fopen('ssh2.sftp://' . intval($sftp) . '/path/to/file', 'r');

//code to get listing of all OUTGOING files
$dir = "ssh2.sftp://$sftp/http";
$outgoing = scanFilesystem($dir);
sort($outgoing);
print_r($outgoing);

vosykapavel avatar Jun 10 '22 16:06 vosykapavel

Error:

Error: file_get_contents(): Read of 8192 bytes failed with errno=13 Permission denied in C:\repositories\deploy
er-test\vendor\dg\ftp-deployment\src\Deployment\Helpers.php:27

came from u trying to open file twice. Put your deployment.php file to ignore files:

return [
	'my site' => [
		'remote' => "ftp://$user:$password@$host:$port/$uploadPath",
		'local' => '.',
		'test' => true,
		'ignore' => '/deployment.php'
         ]
];

emololftw avatar Oct 23 '22 16:10 emololftw