SFTP 连接
当我尝试从 joomla 站点连接 Sftp 时 它没有连接:
$c = ftp_connect('ftp.xyz.com') or die("Can't connect");
ftp_login($c, 'username' , 'pwd') or die("Can't login");
在这种情况下,消息显示无法连接
我也尝试了此代码,
$connection = ssh2_connect('ftp.xyz.com', 22);
if (!$connection) die('Connection failed');
在这种情况下,没有错误消息显示
请帮助我,如果有正确的解决方案,请帮助我。
谢谢
When I' m trying to connect Sftp from my joomla site
its not connecting:
$c = ftp_connect('ftp.xyz.com') or die("Can't connect");
ftp_login($c, 'username' , 'pwd') or die("Can't login");
in this case msg showing Can't connect
I also tried this code
$connection = ssh2_connect('ftp.xyz.com', 22);
if (!$connection) die('Connection failed');
in this case no error msg showing
Please help me, if there is a proper solution help me please.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ftp_connect()
使用 FTP,而不是 SFTP。他们非常不同。因此,如果您的主机仅提供 SFTP,那么不,该功能将无法工作! SFTP 的详细解释如下:http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol
ssh2_connect()
是正确使用的连接方法,这就是它可能有效的原因。您可以在此处查看 PHP 中可用的所有 SSH2 功能:http://php.net/manual /en/ref.ssh2.php
您可能对
ssh2_scp_recv()
和ssh2_scp_send()
(用于获取和发送文件)。ftp_connect()
uses FTP, not SFTP. They're very different. So if your host is providing only SFTP, then no, that function won't work! SFTP is explained in more detail here:http://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol
ssh2_connect()
is the right connection method to use, which is why it's probably working. You can see all the SSH2 functions available in PHP here:http://php.net/manual/en/ref.ssh2.php
You'll probably be most interested in
ssh2_scp_recv()
andssh2_scp_send()
(for getting and sending files).