[英]ssh2_connect define explicit TLS
尝试使用以下代码连接到远程 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:");
这里的结果相同:“连接失败”
ssh2_connect
(和其他ssh2_*
函数)用于 SSH 和 SFTP。
基于 TLS 的显式 FTP 是一个完全不同的协议。 为此,请使用ftp_ssl_connect
和其他ftp_*
函数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.