在远程服务器上用PHP执行Linux命令的最佳方法

时间:2018-10-12 09:09:16

标签: linux security

使用PHP连接到远程VPS并执行Linux命令的最安全方法是什么?

创建远程帐户并按以下方式使用此库?

<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.example.com');
if (!$ssh->login('username', 'password')) {
    exit('Could not logged in');
}
echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
?>

还是使用需要安装PHP和Apache的shell_exec?

0 个答案:

没有答案
相关问题