简体   繁体   中英

Is there a key based auth version of PHP's ftp_login()?

I am trying to change an old piece of code that uses ftp_login() with a username and password to instead use an ssh key I have installed on the server.

I've found phpseclib which seems to be able to do that, but it requires I rewrite the entire section of code (eg ftp_put() would have to become $sftp->put() ) and install that library. Ideally I would only need to replace ftp_login() and nothing would need to be installed.

I haven't come across anything like that in my research, but that hardly means it doesn't exist. Does anyone know of a key based alternative to ftp_login() that isn't phpseclib?

PHP ftp_* functions implement FTP protocol. A public key authentication is used with SFTP protocol (based on SSH).

The SFTP is a completely different protocol than the FTP. So there's absolutely no way, you can use the ftp_* functions for the SFTP (let alone for the public key authentication).

For the SFTP ( even without the public key authentication ), you have to use a different set of functions, like phpseclib or PHP SSH2. And that indeed means a complete rewrite of the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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