How to set a custom SFTP port with phpseclib

戏子无情 提交于 2019-12-02 06:18:43

问题


I have to connect to SFTP server by using PHP. I am using phpseclib for that. I found some example on Internet, but I am not able to connect to SFTP. I am using a custom port (2222) to connect to SFTP. Please tell me where I can define custom port to connect to 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".


回答1:


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:

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

}


来源:https://stackoverflow.com/questions/28231888/how-to-set-a-custom-sftp-port-with-phpseclib

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!