duanmao9918 2011-12-20 03:18
浏览 90
已采纳

在远程服务器上运行Exec()

Can I use PHP exec() to run a terminal command on a remote server? If not, what can I use and how? I need to execute a terminal command on a remote server. What are my options?

  • 写回答

1条回答 默认 最新

  • doupu1957 2011-12-20 03:20
    关注

    You can use ssh2_exec() instead. And very obviously you need permission (= an account) on the remote server and an enabled SSH service. It's quite a standard option for Unix/BSD/Linux servers.

    If you don't have that extension installed, then using ssh via exec() is the next best thing (but requires some setup, you need keys rather than password authorization):

     print exec("ssh user@server 'ls -l'");
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?