Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to exchange encryption keys #158

Open
vosykapavel opened this issue Jun 10, 2022 · 1 comment
Open

Unable to exchange encryption keys #158

vosykapavel opened this issue Jun 10, 2022 · 1 comment

Comments

@vosykapavel
Copy link

vosykapavel commented Jun 10, 2022

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 vosykapavel changed the title Unable to exchange encryption keys | Failure connecting to ssh-agent Unable to exchange encryption keys | Error: file_get_contents(): errno=13 Jun 10, 2022
@vosykapavel vosykapavel changed the title Unable to exchange encryption keys | Error: file_get_contents(): errno=13 Unable to exchange encryption keys Jun 10, 2022
@emololftw
Copy link

emololftw commented Oct 23, 2022

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'
         ]
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants