PHP: SFTP with phpseclib and ssh key
PHP: SFTP with phpseclib and ssh key #webdevelopment
First youāll need download / install phpseclib.
Hereās how to connect to the server with ssh key with this library:
[php highlight=ā8,11ā³] use phpseclib\Crypt\RSA; use phpseclib\Net\SFTP;
$sftp = new SFTP($host); // connect to host
// get the key $key = new RSA(); $key->loadKey(file_get_contents($keyfile));
// connect to server $sftp->login($user, $key);
// now do your sftp operations [/php]
View On WordPress









