phpseclib

来源:互联网 发布:淘宝 全球购 要求 编辑:程序博客网 时间:2024/05/18 18:44

插件-->关于加密、ssh登录、sftp

文档:phpseclib

安装:composer   关于composer安装之后的使用,如下--

<?php require_once __DIR__.'/vendor/autoload.php';use phpseclib\Crypt\AES;use phpseclib\Crypt\RSA;use phpseclib\Net\SSH2;// $aes = new AES();// $aes->setKey('abcdefghijklmnop');// $plaintext = 'hi doma';// echo $aes->decrypt($aes->encrypt($plaintext));// $rsa = new RSA();// extract($rsa->createKey());// $plaintext = 'hi xuan';// $rsa->loadKey($publickey);// $ciphertext = $rsa->encrypt($plaintext);// $rsa->loadKey($privatekey);// echo $rsa->decrypt($ciphertext);// $ssh = new SSH2('192.168.9.137');// if(!$ssh->login('xuan','lwp0fy')){// exit('hehe');// }// echo $ssh->exec('pwd');// $key = new RSA();// $key->loadKey(file_get_contents('/home/doma/.ssh/id_rsa'));// $ssh = new SSH2('192.168.9.137');// if(!$ssh->login('xuan',$key)){// exit('hehe');// }// echo $ssh->exec('pwd');$connection = ssh2_connect('192.168.9.137',22);//$auth_method = ssh2_auth_none($connection, 'xuan');ssh2_auth_password($connection, 'xuan', 'lwp0fy');//ssh2_auth_pubkey_file($connection, 'xuan', "~/.ssh/id_rsa.pub", "~/.ssh/id_rsa"));


备注:这个很实用、具体方法文档写的很全面


0 0