我有一个用PHP编写的网页,我正试图在远程服务器上执行一系列命令。当运行这些命令时,我需要在另一台机器上运行它们,这样我才能通过防火墙。
我所能寻找的一般想法是在远程服务器中执行该命令的输出
foreach ($filter as $filtered) {
echo './script_to_execute_in_a_remote_server '.$filtered
}因此,例如,我将在远程服务器上执行以下命令
./script_to_execute_in_a_remote_server.sh attribute1 attribute2我使用SSH连接到中间服务器,连接到防火墙
ssh root@firewall;从那里,我使用SSH (这次是从防火墙)连接到远程服务器
ssh root@server1;一旦我最终通过SSH连接到远程服务器,就可以执行之前输出的命令了
./script_to_execute_in_a_remote_server.sh attribute1 attribute2我能做到这一点的最好方法是什么?
发布于 2015-03-06 07:08:43
一旦你通过php ssh2连接到防火墙,你就可以通过PHP ssh2会话传递一个常规的cli ssh命令。
ssh root@server1 ./script_to_execute_in_a_remote_server.sh attribute1 attribute2发送此命令将告诉防火墙连接到server1,执行该命令,然后在连接完成后断开连接。
https://stackoverflow.com/questions/28852327
复制相似问题