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









