简体   繁体   English

警告:ftp_login():未登录,需要安全连接

[英]Warning: ftp_login(): Not logged in, need secure connection

How to connect sftp using ftp_connect. 如何使用ftp_connect连接sftp。 I know ssh_connect should work for this. 我知道ssh_connect应该为此工作。 But my server is shared hosting there is no option to enable ssh extension. 但是我的服务器是共享主机,没有启用ssh扩展的选项。

<?php 
    $ftp = ftp_connect('sftp.testsite.com'); 
    echo ftp_login($ftp, 'aaass', 'as333');
?> 

Your help appreciated to resolve this... 感谢您的帮助以解决此问题...

尝试使用ftp_ssl_connect()函数

ssh2_connect is the best way to connect secure connection. ssh2_connect是连接安全连接的最佳方法。 Anyway it will ask the secure connection while your are logging using ftp_connect 无论如何,当您使用ftp_connect进行记录时,它将询问安全连接

$port = 5312;
$connection = ssh2_connect('www.yoursecureserver.com', $port);

Try phpseclib, a pure PHP SFTP implementation . 尝试phpseclib,这是纯PHP SFTP实现 eg. 例如。

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

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

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

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