hanleyhansen
hanleyhansen

Reputation: 6437

Running Exec() on Remote Server

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?

Upvotes: 0

Views: 2468

Answers (1)

mario
mario

Reputation: 145512

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'");

Upvotes: 3

Related Questions