ssh2_connect定义显式TLS

时间:2019-11-27 07:39:25

标签: php ftp ssh2-sftp

尝试使用以下代码连接到远程sftp:

    if( ! function_exists('ssh2_connect') ){
        die( 'Missing ssh2_connect' );
    }

    $callbacks = array(
        'disconnect' => function( $reason, $message, $language ){

            printf("Server disconnected with reason code [%d] and message: %s\n",
           $reason, $message);

        },
        'debug' => array( $this , function( $message, $language, $always_display ){

            printf("%s %s %s\n",$message,$language,$always_display);

        }, )
    );

    $connection = ssh2_connect( $this->ftp_ip , $this->ftp_port , array() , $callbacks ) or die("Connection failed:");

    ssh2_auth_password($connection, $this->ftp_user , $this->ftp_pass );

    $sftp = ssh2_sftp($connection);

我得到的结果是“连接失败”

远程sftp服务器需要基于TLS的显式FTP(这是我使用Filezilla进行连接的方式-连接正常)

如何使用ssh2_connect定义基于TLS的显式FTP?

编辑 尝试也使用ftp_ssl_connect

连接
$connection = ftp_ssl_connect( $this->ftp_ip , $this->ftp_port ) or die("Connection failed:");

此处结果相同:“连接失败”

0 个答案:

没有答案