SSH in PHP script.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
LindaH
Forum Newbie
Posts: 1
Joined: Mon Nov 08, 2004 2:26 am

SSH in PHP script.

Post by LindaH »

Hi.
I am making a tool page for a few servers. In order to start some things up, we now use the shell commands using SSH. What we plan is to have one tool page on the main server. That can start those, so people can start those. I need a way to connect and generate these shell commands from the PHP script.
Is there a class for SSH connection for PHP? Or how can I do this?

L
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

most intuitive way would be to call command line ssh client via [php_man]shell_exec[/php_man], like this:

Code: Select all

//.......
$output = shell_exec('ssh -i /path/to/cert.file someone@example.com command_to_execute');
//.......
Post Reply