donglong2856 2015-01-30 08:23
浏览 191

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

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条回答 默认 最新

  • duanniedang3946 2015-01-30 08:26
    关注

    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)
    {
    
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn