简体   繁体   English

如何使用phpseclib设置自定义SFTP端口

[英]How to set a custom SFTP port with phpseclib

I have to connect to SFTP server by using PHP. 我必须使用PHP连接到SFTP服务器。 I am using phpseclib for that. 我为此使用phpseclib。 I found some example on Internet, but I am not able to connect to SFTP. 我在Internet上找到了一些示例,但是无法连接到SFTP。 I am using a custom port (2222) to connect to SFTP. 我正在使用自定义端口(2222)连接到SFTP。 Please tell me where I can define custom port to connect to SFTP. 请告诉我在哪里可以定义自定义端口以连接到SFTP。

<?php
include('Net/SFTP.php');

$sftp = new Net_SFTP('www.domain.tld');
if (!$sftp->login('username', 'password')) {
    exit('Login Failed');
}
?>

It is showing "Login Failed". 它显示“登录失败”。

You can define a custom port like so: 您可以像这样定义自定义端口:

Net_SFTP('www.domain.tld', 2222);

You can see it when you look in the constructor from SFTP class which is like this: 当您从SFTP类中查看构造函数时可以看到它,如下所示:

function Net_SFTP($host, $port = 22, $timeout = 10)
{

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM